# D3DXMATRIXA16 and std::vector

## Recommended Posts

I have a problem that basically I am stumped on. It goes a little something like this.
#include <vector>
#include <Windows.h>
#include <d3dx9.h>

class Bullshit
{
public:
D3DXMATRIXA16 m_mat;
};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
std::vector <Bullshit> vec;
return(0);
}


That's the little test program I made to ensure I wasn't insane. When I compile it, I get this error:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(507) : error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned
d:\Mezz\Poo\App.cpp(14) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=Bullshit
]

If I take out the matrix member, it's fine. If I make it a vector of pointers to the class, it's fine. But why doesn't it work like that? I would prefer to use a 16-byte aligned matrix if possible... -Mezz

##### Share on other sites
This is what MSDN has to say. I don't know how to solve it though.

##### Share on other sites
I was just struggling a bit with a similar issue - then it occurred to me that, yeah, how could a function (or template) parameter be 16-byte aligned? Sure it could be, but it's not guarenteed, thus attempts to do SSE/SSE2 ops on the incoming argument could fault.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628357
• Total Posts
2982225

• 10
• 9
• 9
• 24
• 11