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

ぃ、小莉子 提交于 2019-12-01 03:17:31

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!