【发布时间】:2014-07-24 02:27:47
【问题描述】:
我得到了这个联合,我正在尝试使用 gcc 4.8 对齐到 16 字节边界。
typedef union {
unsigned long long int ud[(1<<6)/8];
long long int d[(1<<6)/8];
unsigned int uw[(1<<6)/4];
int w[(1<<6)/4];
short uh[(1<<6)/2];
unsigned short int h[(1<<6)/2];
unsigned char ub[(1<<6)/1];
char b[(1<<6)/1];
} vector_t;
我试过了
vector_t __attribute__ ((aligned(16))) t;
但它不起作用。堆栈中变量 t 的地址未与 16 字节对齐。
我能够在 VS 10 中使用 __declspec align(16) 对其进行对齐。请让我知道在 gcc 中执行此操作的方法是什么。
【问题讨论】:
-
你的意思是 16 位边界?我认为不可能对
unsigned long long或任何其他大于 4 字节的数据类型进行半字对齐。不过,我可能错了。