更新:2007 年 11 月
错误消息
“parameter”: 具有 __declspec(align('#')) 的形参将不被对齐函数参数中不允许使用 align__declspec 修饰符。
下面的示例生成 C2719:
// C2719.cpp void func(int __declspec(align(32)) i); // C2719 // try the following line instead // void func(int i);
注意收集错误信息,通过“输出”窗口,定位到具体代码行!!!
解决方案:
http://eigen.tuxfamily.org/dox/TopicStlContainers.html
eigen 3.1.2有 bug,
更新daily build版本: (官网 https://bitbucket.org/eigen/eigen/)
hg clone https://bitbucket.org/eigen/eigen/
并修改 RealScalar p => const RealScalar& p
关于为何更改的网页找不到了。。。 大致意思是这个: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=83
msvc2008才会出现此错误,2010没有。
解释大致为:
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.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2012-03-13 19:34:36| 分类:reproduct| 标签:eigenvs2010|字号大中小订阅
英文提示:error C2719: 'p': formal parameter with __declspec(align('16')) won't be aligned 中文提示:error C2719: “p”: 具有 __declspec(align('16')) 的形参将不被对齐 导致整个现象的主要原因是使用了Eigen库,Eigen为了使用SSE加速,所以内存分配上使用了128位的指针。 更加准确的说法: “First, "fixed-size" should be clear: an Eigen object has fixed size if its number of rows and its number of columns are fixed at compile-time. So for example Matrix3f has fixed size, but MatrixXf doesn't (the opposite of fixed-size is dynamic-size). The array of coefficients of a fixed-size Eigen object is a plain "static array", it is not dynamically allocated. For example, the data behind a Matrix4f is just a "float array[16]". Fixed-size objects are typically very small, which means that we want to handle them with zero runtime overhead -- both in terms of memory usage and of speed. Now, vectorization (both SSE and AltiVec) works with 128-bit packets. Moreover, for performance reasons, these packets need to be have 128-bit alignment. So it turns out that the only way that fixed-size Eigen objects can be vectorized, is if their size is a multiple of 128 bits, or 16 bytes.Eigen will then request 16-byte alignment for these objects, and henceforth rely on these objects being aligned so no runtime check for alignment is performed.” 解决方案: 分为四种情况:
每种情况可以对照官方的说法。可以参考如下链接 http://eigen.tuxfamily.org/dox/TopicUnalignedArrayAssert.html 在此不再重复表述。 |
http://eigen.tuxfamily.org/dox/TopicUnalignedArrayAssert.html#c3
Table of contents
更新:2007 年 11 月
函数参数中不允许使用 align__declspec 修饰符。
下面的示例生成 C2719:
// C2719.cpp void func(int __declspec(align(32)) i); // C2719 // try the following line instead // void func(int i);