使用 __attribute__((packed))
例如
struct TEST {
short x;
int y;
}__attribute__((packed));
此时sizeof(TEST)等于6,可见此时不是自动对齐
或者使用#pragma pack,详见百度百科