The one and only objection to C
Doug Gwyn <gwyn>
gwyn at brl-tgr.ARPA
Wed Dec 26 15:06:35 AEST 1984
> why in the world does most C compilers insist on padding structures?
On some architectures, there are alignment restrictions such that data
of a particular type must be stored at an address that is a multiple
of some number of bytes, in order to be directly accessible; e.g., on a
PDP-11 all non-char data must be stored at an even-byte address. The C
run-time environment designer takes these and other things into account
when deciding how to align structure members.
On a fully byte-addressable machine, no struct padding should be used.
On the VAX, a silly decision was made. In spite of the fact that there
are no alignment constraints imposed by the architecture, the VAX PCC
implementors nevertheless chose to align data in order to take into
account the way the 11/780 cache was designed. The idea was to squeeze
a small speed improvement out of the VAX-11/780. I wonder if the scheme
continued to accomplish its goal on other VAX models?
More information about the Comp.lang.c
mailing list