Un-alignment in structures

Eugene D. Brooks III brooks at lll-crg.ARPA
Mon Apr 1 17:16:19 AEST 1985

I find the argument for having packet structures to save memory reasonable.
This is a genuine concern in many codes.  An example of this would be a
simulation code for a packet switching system where the packets have many
fields of different types.  When I write such codes I find myself carefully
ordering the structure declarations to minimize the effects of padding.

Would lifting the restriction on the addressing order of structure elements
fill this need without any changes to the sematics of C?  Suppose the compiler
were free to reorder the elements of a structure in order to minimize padding.
Would it break any code?  Are there programs (other than I/O portability) that
depend on structure elements being ordered in memory with the same order as
the delcarations?

More information about the Comp.lang.c mailing list