错误C2719:'_Val“:用__declspec形式参数(对齐('16'))将不会被一致? [英] error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned?
问题描述
我试图创建 D3DXMATRIXA16
像这样一个向量:矢量< D3DXMATRIXA16>矩阵;
和正在错误:
D:\ Program Files文件\微软的Visual Studio 9.0 \ VC \包括\向量(717):
错误C2719:'_Val:形式参数 与__declspec(对齐('16'))将不 排列
E:\项目\ emuntitled \ EM \ emscratch \ emshadow.h(60):
:见参考文献类模板 实例化'的std ::矢量< _Ty>是 编译 同 [ _Ty = D3DXMATRIXA16 ]
这是为什么什么呢?
感谢您的帮助!
这是一个的已知的问题的那个的stl ::向量不能正确地包含对齐的数据,如D3DXMATRIXA16。一个海报钉扎的根源的(或至少一的他们):矢量::调整大小的声明价值传递一致的数据,而不是常引用。 有几个解决方法是建议在该线程,最安全的幸福的完全丢弃STL ::矢量的。您可能还需要修复STL头自己,重新编译 - 这实际上可能会更容易比它的声音,但我没有这样做我自己。
。编辑:链接现在破(感谢@大卫梅纳尔),这里的另一种选择,更详细的答案。
该问题已在VS2012RC - 这里有一个链接,相应的连接问题。原来这实际上是一个问题,在C ++标准本身,定格在2008年。
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 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. Turns out it was actually an issue in the C++ standard itself, fixed in 2008.
这篇关于错误C2719:'_Val“:用__declspec形式参数(对齐('16'))将不会被一致?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!