0
votes

I have some problems with compiling my code. There are couple of functions which can't be compiled because of error C2719 - formal parameter with __declspec(align('16')) won't be aligned.

Functions which VisualStudio can't compile look like that

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;
    }
}

It's quite strange because of the fact that previously I used MatrixXd instead of Vector2d and Matrix2d and everything was fine. What is more this is common problem when using stl:vector - however as You can see this functions doesn't take as a parameter stl:vector.

What can I do to fix this?

1
What does std::vector have to do with anything? - Oliver Charlesworth
During reaserch of how to fix this problem , I found out that this is common error when using stl:vector - at least I think that :) - george
Post a complete, minimal program that demonstrates the problem. - genpfault
-1 ** translation? That seems off. - Puppy
Why is the first parameter passed by value, and the others by pointer? The compiler hasn't figured out the runtime stack alignment at each point of call, so it will just not guarantee 16 byte alignment for function parameters. - Bo Persson

1 Answers

3
votes

Compiler error C2719 has nothing to do with STL, it is telling you that you are not allowed to use the 'align' __declspec modifier on formal parameter declarations.

To fix your problem, you need to declare your functions without using __declspec(align (...)). Of course you aren't explicitly using __declspec so really you need to figure out how/why it is being used on your behalf.

A good place to start might be the definition of Eigen::Matrix2d.