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!
It is a known issue [link dead] 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.
EDIT: links are now broken (thanks @David Menard), here's an alternative, more elaborate answer.
The issue is fixed in VS2012RC - here's a link to a corresponding connect issue [link dead]. Turns out it was actually an issue in the C++ standard itself, fixed in 2008.
It looks like the std::vector class requires the template parameter to be align(1); likely for some sort of fast indexing.