Structure padding and packing

Padding aligns structure members to “natural” address boundaries – say, int members would have offsets, which are mod(4) == 0 on 32-bit platform. Padding is on by default. It inserts the following “gaps” into your first structure: Packing, on the other hand prevents compiler from doing padding – this has to be explicitly requested – under GCC it’s __attribute__((__packed__)), so the following: … Read more