structure element order.
j.p.schoonover
jps at cbnewsd.att.com
Sat Apr 13 07:54:29 AEST 1991
> A question really, does the standard *guarantee* the physical order of structure
> elements ? I looked in K&R 2 and couldn't find anything.
>
> Like, my smart compiler couldn't decide to 'shuffle' them around for reasons
> best known to itself could it ?, ... or could it ?
>
> IMHO the technique used above is inferior to using char *filename and mallocing
> the space separately simply for reasons of clarity, and if a compiler might
> shuffle structure elements around it could one day lead to some rather curious
> bugs ...
>
> Harry
> ---
> (smart Internet mailers) harry.protoolis at uk.sun.com
> (smart JANET mailers) harry.protoolis at sun-microsystems.co.uk
> (dumb uucp mailers) ...!sun!sunuk!harry.protoolis
>
> 'When I give food to the poor they call me a saint.
> When I ask why the poor have no food they call me a communist.'
> - Dom Helder Camara
>From page 213 of K&R 2
"The members of a structure have addresses increasing in the order of
their declarations."
>From this I would say that the compiler cannot shuffle the order of the
structure elements.
J. P. Schoonover
iwsgw!jps
More information about the Comp.lang.c
mailing list