0

我在编译代码时遇到了一些问题。由于错误 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 作为参数。

我能做些什么来解决这个问题?

4

1 回答 1

3

编译器错误C2719与 STL 无关,它告诉您不允许在形式参数声明中使用 'align' __declspec 修饰符。

要解决您的问题,您需要在不使用 __declspec(align (...)) 的情况下声明您的函数。当然,您没有明确使用 __declspec,因此您确实需要弄清楚它是如何/为什么代表您使用的。

一个好的起点可能是 Eigen::Matrix2d 的定义。

于 2011-06-01T22:52:26.083 回答