找到了一些文档。
http://docs.freebsd.org/info/gcc ... ble_Attributes.html
做如下定义。
struct test{
int num;
char c;
};
struct test temp1;
struct test temp2 __attribute__ ((aligned (1)));
struct test temp3 __attribute__ ((aligned (2)));
struct test temp4 __attribute__ ((aligned (4)));
struct test temp5 __attribute__ ((aligned (8)));
struct test temp6 __attribute__ ((aligned (16)));
struct test temp7 __attribute__ ((aligned (32)));
printk("&temp1=0x%x,&temp2=0x%x,&temp3=0x%x,&temp4=0x%x,&temp5=0x%x,&temp6=0x%x,&temp7=0x%x\n",&temp1,&temp2,&temp3,&temp4,&temp5,&temp6,&temp7);
比较一下这些地质就能看出差别来了。
TO 黄富强:
能否贴出用# define --------&---例子让我试验一下。谢谢!