C 将并集与x86中的16字节边界对齐。
我得到了这个联合体,我正试图使用GCC4.8将其与16字节边界对齐C 将并集与x86中的16字节边界对齐。,c,gcc,C,Gcc,我得到了这个联合体,我正试图使用GCC4.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]
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;
但它不起作用。堆栈中变量t的地址未与16字节对齐
我能够在VS 10中使用_declspec align(16)对齐它。请让我知道在gcc中如何做到这一点 关键字
\uuuu attribute\uuuu
允许您在定义struct
和union
类型时指定这些类型的特殊属性。你需要做什么
typedef union __attribute__ ((aligned(16))) {
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;
typedef联合属性(对齐(16))){
unsigned long long int ud[(1您是指16位边界?我认为不可能将unsigned long
或任何其他大小大于4字节的数据类型对半字对齐。不过,我可能错了。确切地说,您需要定义关键字:-)换句话说,属性是类型的一部分,而不是它的特定实例的一部分
typedef union __attribute__ ((aligned(16))) {
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;