我在编译代码时遇到了一些问题。有几个函数由于错误 C2719 而无法编译 - 带有 __declspec(align('16')) 的形式参数不会对齐。
VisualStudio 无法编译的函数看起来像这样
Eigen::Matrix2d AlgorithmBase::ReverseTransform(Eigen::Vector2d point, Eigen::Vector2d *translation, Eigen::Matrix2d *scaling, double phi, Eigen::Matrix2d *share)
{
Eigen::Matrix2d reversedScaling;
reversedScaling(0,0) = 1/(*scaling)(0,0);
reversedScaling(0,1) = reversedScaling(1,0) = 0;
reversedScaling(1,1) = 1/(*scaling)(1,1);
Eigen::MatrixXd newTranslation = -1**translation;
return MatrixHelper::CreateRotationMatrix(-phi)* *scaling*point + newTranslation;
}
void TemplateClusterBase::SetScalingMatrix( Eigen::Matrix2d matrix )
{
if(matrix.rows() == 1 || matrix.cols()==1)
{
this->scalingMatrix = MatrixHelper::CreateScalingMatrix(matrix(0,0));
}
else
{
this->scalingMatrix = matrix;
}
}
这很奇怪,因为之前我使用 MatrixXd 而不是 Vector2d 和 Matrix2d,一切都很好。更重要的是,这是使用 STL:vector 时的常见问题 - 然而正如您所见,此函数并未将 STL:vector 作为参数。
我该怎么做才能解决这个问题?
最佳答案
编译器错误 C2719与 STL 无关,它告诉您不允许在形式参数声明中使用“对齐”__declspec 修饰符。
要解决您的问题,您需要在不使用 __declspec(align (...)) 的情况下声明您的函数。当然,您没有明确使用 __declspec,所以您真的需要弄清楚它是如何/为什么代表您使用的。
一个好的起点可能是 Eigen::Matrix2d 的定义。
关于c++ - 头文件中的错误 C2719 - 不使用 STL :vector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6208262/