C语言结构对齐:
1. 结构中基本数据成员(char,short,int,double等)的偏移地址按自己大小的整数倍
2. 结构中有结构的,结构成员的偏移地址按此结构成员的最大基本数据成员整数倍
3. 结构总的大小是最大基本数据成员的整数倍
typedef struct {
char x1;
short x2;
int x3;
char x4;
}test;
test.x1: 0
test.x2: 2
test.x3: 4
test.x4: 8
sizeof(test) = 9 + 3(填充3个字节才能被4整除,12%4==0)
typedef struct {
char y1;
test y2;
}test1;
test1.y1: 0
test1.y2: 4
sizeof(test1) = 4+12 = 16