indiehjaerta
indiehjaerta

Reputation: 341

XMMATRIX and formal parameter with __declspec(align('16')) won't be aligneD

I've tried migitating my old DirectX code to a newer one in Visual Studio 2013.

In Scene.cpp I have the function

void AddInstance(Instance aInstance);

Which is just a push_back:

m_vecInstances.push_back(aInstance);

This gives an error saying:

Error   1   error C2719: 'aInstance': formal parameter with __declspec(align('16')) won't be aligned

The reason is Instance.h member has DirectX::XMMATRIX m_Orientation; and I don't understand how to solve this. I found answers saying DirectX::XMFLOAT4X4 but I rather don't

I'm guessing I could swap out std::vector but I think that also would just be walking around the problem.

Any answer that solves my problem would make my day <3

Upvotes: 2

Views: 1625

Answers (1)

MuertoExcobito
MuertoExcobito

Reputation: 10049

DirectX::XMMATRIX __declspec(align('16')) won't be aligned

Although it's a slightly different situation than the answer to this question, the solution is the same - pass Instance by const reference into the AddInstance function.

void AddInstance(const Instance& aInstance);

Upvotes: 3

Related Questions