Structure Padding and Packingsuggest change
By default, C compilers lay out structures so that each member can be accessed fast, without incurring penalties for ’unaligned access, a problem with RISC machines such as the DEC Alpha, and some ARM CPUs.
Depending on the CPU architecture and the compiler, a structure may occupy more space in memory than the sum of the sizes of its component members. The compiler can add padding between members or at the end of the structure, but not at the beginning.
Packing overrides the default padding.
Eric Raymond has an article on The Lost Art of C Structure Packing which is useful reading.
Found a mistake? Have a question or improvement idea? Let me know.
Table Of Contents