This tip has been extracted from the main structure padding article.
Compilers might shift the offset of structure members so that they are aligned on device-specific memory boundaries and can be easily accessed. This padding forms part of the structure and can result in the size of a structure being larger than the sum of the sizes of its members.
You should never make assumptions about the size of structures, and you should always use the sizeof() operator to obtain a structure’s size. Do not assume that a structure member follows immediately in memory after the previous member. Always use the address operator, &, to obtain the address of a structure member. Structure padding implies that you should be careful using a char pointer to access each byte of a structure, since some of those bytes might be padding and hold meaningless values.
Some compilers might pack structure members on an alignment which is equal to the size of that member, so the ordering of the members can affect the structure size. Placing members with the same size sequentially might result in smaller-sized structures.
Microchip Technology acquires Atmel