Jump to content


16-byte aligned vectors with GCC


1 reply to this topic

#1 Nick

    Senior Member

  • Members
  • PipPipPipPip
  • 1227 posts
  • LocationOttawa, Ontario, Canada

Posted 24 September 2006 - 10:20 AM

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?

Nick

#2 Kenneth Gorking

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 24 September 2006 - 05:26 PM

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...
"Stupid bug! You go squish now!!" - Homer Simpson





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users