Zarovávání paměti datových struktur

struct MixedData  /* After compilation in 32-bit x86 machine */
{
    char Data1; /* 1 byte */
    char Padding1[1]; /* 1 byte for the following 'short' to be aligned on a 2 byte boundary 
assuming that the address where structure begins is an even number */
    short Data2; /* 2 bytes */
    int Data3;  /* 4 bytes - largest structure member */
    char Data4; /* 1 byte */
    char Padding2[3]; /* 3 bytes to make total size of the structure 12 bytes */
};
struct FinalPad {
  float x;
  char n[1];
};
struct FinalPad __attribute__((packed)) {
  float x;
  char n[1];
};

Zdroje

Data structure alignment