Order of allocation of fields in a struct?

Don Lewine lewine at dg.dg.com
Fri Jun 15 02:11:53 AEST 1990


In article <1563 at diemen.cc.utas.oz> charles at tasis.eecs.utas.edu.au (Charles Lakos) writes:
>I wonder if the C standard says anything about the order of allocation of 
>memory to fields of a struct.
	Yes.  See section 3.1.2.5 and section 3.5.2.1 which says, "Within 
	a structure object ... members have addresses that increase in the
	order that they are declared.  ... There may be unnamed holes within
	a structure, but not at its beginning, as necessary to achieve the
	appropriate alignment."


>Can I then access the fields of v2 in the following way:
>  (t1 *) p -> b

	Yes.

Donald Lewine
uunet!dg!lewine     -OR-
uunet!ptech!don     -OR-   
Don_Lewine at dgc.ceo.dg.com



More information about the Comp.std.c mailing list