Data structure padding

Processors require that certain types of data have particular alignments. For example, a processor might require that an int be on a 4-byte boundary. So, for example, an int could start at memory location 0x4000 but it could not start at 0x4001. So if you defined a class:

class a
{
public:
    char c;
    int i;
};

the compiler would have to insert padding between c and i so that i could start on a 4-byte boundary.

Leave a Comment