#include <stdio.h>
// 默认对齐
struct DefaultAligned {
char c;
int i;
};
// 按1字节对齐
#pragma pack(push, 1)
struct OneByteAligned {
char c;
int i;
};
#pragma pack(pop) // 恢复之前的对齐设置
int main() {
printf("Size of DefaultAligned: %zu bytes\n", sizeof(struct DefaultAligned));
printf("Size of OneByteAligned: %zu bytes\n", sizeof(struct OneByteAligned));
return 0;
}