该代码时基于linux下的
#include<stdio.h>
typedef struct attr {
char date_1;
int number;
char date_2
} attr;
typedef struct bute {
char data_1;
int num;
char data_2;
}__attribute__((packed))bute;
typedef struct trib {
char table;
int star;
char tables;
}__attribute__((aligned(8)))trib;
int main() {
printf("sizeof(attr)==%d sizeof(bute)==%d trib == %d\n",sizeof(attr),sizeof(bute),sizeof(trib));
return 0;
}
运行截图:
attr是以自动对其的方式进行对其的
bute是按照最小变量的对其方式对其的
trib是按照字节指定的对其方式对其的