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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…