Overzealous alignment and padding

Larry Jones scjones at sdrc.UUCP
Sat Oct 15 08:49:29 AEST 1988


I am looking for information about C compilers that are overzealous
about aligning structure members and padding structures.  By this
I mean that the compiler aligns more strictly than is required by
the underlying hardware - for example, aligning an array of char
on an int boundary rather than a char boundary.  Similarly, a
structure may be padded out to an even number of ints even though
all the members are only char.

Although this behavior is acceptable under the draft ANSI
standard, it makes it impossible to declare a struct that
conforms to some external format (e.g. records in a file).  If a
compiler does this by default but has some way to prevent it,
please let me know what compiler and how to disable it (e.g.
compiler switch, pragma, etc.).  If a compiler doesn't have a way
to disable it, I DEFINITELY what to know!

If there are lots of compilers like this (which I doubt since
I've just run into my first and I've dealt with LOTS before),
then we're going to have to do a major rethink of a product we
were just about to announce.  If there are only a few (fingers
crossed), we can just write them off.

If you know of a compiler like this, please mail me the info and
I will summarize.

----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at sdrc.uucp
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150                  AT&T: (513) 576-2070
"Save the Quayles" - Mark Russell



More information about the Comp.lang.c mailing list