While I understand how padding generally works in a C struct, I struggle to understand how inner struct are padded. Example:
struct inner
{
int a;
}
struct outer
{
char a;
struct inner b;
}
How is the padding between member outer.a
and member outer.b
calculated?
How is the padding of the end of struct outer
calculate when the data type of member inner.a
changes from int
to short
or double
?
What are the implications of calculating these paddings in a 32 bit architecture versus a 64 bit one?