16-byte aligned vectors with GCC

Nick 102 Sep 24, 2006 at 10:20

Hi all,

I’m trying to port the following Visual C++ code to GCC:

typedef __declspec(align(16)) float float4[4];

This defines a new type, float4, which is an array of four floats, aligned on 16 bytes. GCC has an __align(16) specifier, which is almost equivalent to __declspec(align(16)), but it is not allowed in typedefs for some reason. I tried creating an aligned float4 struct type, but oddly this doesn’t compile either. I’d really love to be able to use float4 directly everywhere I need an aligned vector.

Any ideas?


1 Reply

Please log in or register to post a reply.

Kenneth_Gorking 101 Sep 24, 2006 at 17:26

Don’t see why it wouldn’t work, i use this:

class __attribute__((aligned(16))) Vector

and it compiled just fine the last time I compiled it using GCC, they might have changed it though…