views:

669

answers:

2

I'm trying to create a vector for D3DXMATRIXA16 like so: vector<D3DXMATRIXA16> matrices; and am getting the error:

     d:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(717) :

error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned

    e:\projects\emuntitled\em\emscratch\emshadow.h(60) :

:see reference to class template instantiation 'std::vector<_Ty>' being compiled with [ _Ty=D3DXMATRIXA16 ]

Why is that exactly?

Thanks for any help!

+2  A: 

It looks like the std::vector class requires the template parameter to be align(1); likely for some sort of fast indexing.

gatorfax
+3  A: 

It is a known issue that stl::vector cannot properly contain aligned data, such as D3DXMATRIXA16. One poster pinned the root cause (or at least, one of them?): the declaration of vector::resize passes the aligned data by value, and not as const reference. Several workarounds were suggested in that thread, the safest being dropping stl::vector altogether. You might also want to fix the stl headers yourself and recompile - this actually may be easier than it sounds, but I haven't done so myself.

Ofek Shilon