Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!gvlf3.gvl.unisys.com!tredysvr!cellar!rogue From: rogue@cellar.UUCP (Rogue Winter) Newsgroups: comp.lang.c Subject: Re: Variable structure size -- ANSI ? Message-ID: <1D6c12w164w@cellar.UUCP> Date: 13 Apr 91 22:23:35 GMT References: <1991Apr12.234258.23800@ism.isc.com> Sender: bbs@cellar.UUCP (The Cellar BBS) Organization: The Cellar BBS and public access system Lines: 32 willcr@bud.sos.ivy.isc.com (Will Crowder) writes: > The ANSI standard guarantees that elements of a structure will be allocated > in the order declared. However, there may be any amount of padding between > structure elements. But yes, for > > struct foo { > int a; > int b; > }; > > &foo.b is guaranteed to be greater then &foo.a. Also, &foo is guaranteed > to be equal to &foo.a. > Just a quick follow-up question: while struct foo { short a; short b; } is guaranteed to produce &b > &a, will struct bar { short a,b; } also be guaranteed, or will the pointer order be compiler-dependent? Rogue Winter : "How can you say I only protected people in South rogue@cellar.uucp : Philadelphia? I protected people all over this city; it uunet!cellar!rogue: didn't matter if they were in South Philadelphia or Cellar 215/3369503: Northeast Philadelphia." -- Frank Rizzo, 4/12/91