注意点:记得要两条下滑线__,这个不能忘了输入,还有就是这个不需要头文件。 1、__attribute__((packed));告诉编译器结构体在编译过程中取消优化对齐,有助于我们对地址空间的应用。 2、__attribute__((aligned(8)));告诉编译器该结构体以8字节进行字节对齐,也可以设置别的数据。 3、__attribute__((at(0x1234)));用于设置的结构体或者变量的起始地址为该地址,地址可以改变。
struct test
{
unsigned short RFU2;
unsigned char Revision;
}__attribute__((packed));
空间大小3
struct test
{
unsigned short RFU2;
unsigned char Revision;
}__attribute__((aligned(8)));
空间大小16
unsigned char APP_MAC[6] __attribute__((at(0x1234))); APP_MAC的起始地址为0x1234



