c++ - 头文件中的错误 C2719 - 不使用 STL :vector

标签 c++ stl eigen

我在编译代码时遇到了一些问题。有几个函数由于错误 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/

相关文章:

c++ - 混合音频 channel

c++ - 将矩阵附加到 STL 矩阵(2d std::vector)

c++ - 划分集合 (C++)

c++ - Eigen :比较两个可能具有不同稀疏模式的稀疏矩阵

C++/Eigen : Get type of matrix argument to a template written for MatrixBase

c++ - ofstream/fstream 根本行不通,无论尝试什么解决方案

c++ - 进入系统,Linux下的CRTL功能与Eclipse

c++ - 无法将 SQLINTEGER* 转换为 SQLLEN* (x64)

c++ - 在运行时指定的多个谓词

c++ - 如何在 Atmel Studio 7 中为 Arduino 使用 Eigen 库?