Order of allocation of fields in a struct?

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Jun 15 05:02:05 AEST 1990


In article <1563 at diemen.cc.utas.oz> charles at tasis.eecs.utas.edu.au (Charles Lakos) writes:
>Can I then access the fields of v2 in the following way:
>  (t1 *) p -> b

No, but ((t1 *)p)->b should work.

You can count on a pointer to the first member of a struct being
convertible to a pointer to the struct and vice-versa, and from
various constraints in the standard it is possible to conclude
that "all structure pointers smell the same", meaning that they
have the same size and alignment requirements, so it is also
possible to interconvert pointers to two different structure
types.



More information about the Comp.std.c mailing list