Memory alignment in C
- by user1758245
Here is a snippet:
#pragma pack(4)
struct s1
{
char a;
long b;
};
#pragma pack()
#pragma pack(2)
struct s2
{
char c;
struct s1 st1;
};
#pragma pack()
#pragma pack(2)
struct s3
{
char a;
long b;
};
#pragma pack()
#pragma pack(4)
struct s4
{
char c;
struct s3 st3;
};
#pragma pack()
I though sizeof(s4) should be…