Should I convert FORTRAN code to C?

T. William Wells bill at proxftl.UUCP
Wed Jul 6 08:27:36 AEST 1988


In article <861 at garth.UUCP>, smryan at garth.UUCP (Steven Ryan) writes:
> I have seen the error of my ways!  I now see that similarity of casting
> (int)(1.2) to (struct a*)(struct-b*-value). Obviously truncating an floating
> point number is the same as accessing the identical bit pattern as two
> distinct structs.

The expression (int)(1.2) means convert the floating point
constant to an integer. This involves a representation change.
The expression (struct a *)b, where b is a pointer to a struct b,
also involves a representation change. For technical reasons,
almost all compilers represent all structure pointers the same,
thus making the representation change the identity
transformation.  The cast you mentioned is of POINTERS, not
structures. In fact, casting a structure is not legal in C.



More information about the Comp.lang.c mailing list