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

2

10

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!

Tenedos answered 15/8, 2009 at 7:52 Comment(1)
Can you post the code where you use it?Dibbell
L
15

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.

Lavallee answered 26/2, 2010 at 9:57 Comment(0)
A
2

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

Ardent answered 17/8, 2009 at 15:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.