DirectX 11 xnamath.h

I tried to run an example from some book using DirectX 11.
I downloaded directX SDK, and copied xnamath.h and the files it use to the folder of the code (xnamath.h and another 4 .inl files). But when I tried to compile it, the compiler prints a very long list of warning and error massages. This is the code and the errors are listed below.

#include <windows.h> // for FLOAT definition
#include "xnamath.h"
#include <iostream>
using namespace std;

int main()
{
cout.precision(8);

// Check support for SSE2 (Pentium4, AMD K8, and above).
if( !XMVerifyCPUSupport() )
{
cout << "xna math not supported" << endl;
return 0;
}
XMVECTOR u = XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f);
XMVECTOR n = XMVector3Normalize(u);

float LU = XMVectorGetX(XMVector3Length(n));

cout << LU << endl;
if( LU == 1.0f )
cout << "Length 1\n";
else
cout << "Length not 1\n";

float powLU = powf(LU, 1.0e6f);
cout << "LU^(10^6) = " << powLU << endl;
}

The start of the list of the errors:

In file included from example1.cpp:2:0:
xnamath.h:2926:8: warning: extra tokens at end of #endif directive [enabled by d
efault]
In file included from xnamath.h:2930:0,
from example1.cpp:2:
xnamathconvert.inl:3935:8: warning: extra tokens at end of #endif directive [ena
bled by default]
xnamathconvert.inl:5409:8: warning: extra tokens at end of #endif directive [ena
bled by default]
xnamathconvert.inl:5449:8: warning: extra tokens at end of #endif directive [ena
bled by default]
In file included from example1.cpp:2:0:
xnamath.h:217:48: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:242:3: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:256:3: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:270:3: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:284:3: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:309:35: error: 'XMVECTOR operator+(FXMVECTOR)' must have an argument o
f class or enumerated type
xnamath.h:310:35: error: 'XMVECTOR operator-(FXMVECTOR)' must have an argument o
f class or enumerated type
xnamath.h:312:51: error: 'XMVECTOR& operator+=(XMVECTOR&, FXMVECTOR)' must have
an argument of class or enumerated type
xnamath.h:313:51: error: 'XMVECTOR& operator-=(XMVECTOR&, FXMVECTOR)' must have
an argument of class or enumerated type
xnamath.h:314:51: error: 'XMVECTOR& operator*=(XMVECTOR&, FXMVECTOR)' must have
an argument of class or enumerated type
xnamath.h:315:51: error: 'XMVECTOR& operator/=(XMVECTOR&, FXMVECTOR)' must have
an argument of class or enumerated type
xnamath.h:316:45: error: 'XMVECTOR& operator*=(XMVECTOR&, FLOAT)' must have an a
rgument of class or enumerated type
xnamath.h:317:45: error: 'XMVECTOR& operator/=(XMVECTOR&, FLOAT)' must have an a
rgument of class or enumerated type
xnamath.h:319:50: error: 'XMVECTOR operator+(FXMVECTOR, FXMVECTOR)' must have an
argument of class or enumerated type
xnamath.h:320:50: error: 'XMVECTOR operator-(FXMVECTOR, FXMVECTOR)' must have an
argument of class or enumerated type
xnamath.h:321:50: error: 'XMVECTOR operator*(FXMVECTOR, FXMVECTOR)' must have an
argument of class or enumerated type
xnamath.h:322:50: error: 'XMVECTOR operator/(FXMVECTOR, FXMVECTOR)' must have an
argument of class or enumerated type
xnamath.h:323:44: error: 'XMVECTOR operator*(FXMVECTOR, FLOAT)' must have an arg
ument of class or enumerated type
xnamath.h:324:44: error: 'XMVECTOR operator*(FLOAT, FXMVECTOR)' must have an arg
ument of class or enumerated type
xnamath.h:325:44: error: 'XMVECTOR operator/(FXMVECTOR, FLOAT)' must have an arg
ument of class or enumerated type
xnamath.h:372:3: warning: 'align' attribute directive ignored [-Wattributes]
xnamath.h:408:30: warning: attribute ignored in declaration of 'struct XMFLOAT2A
' [enabled by default]
xnamath.h:408:30: warning: attribute for 'struct XMFLOAT2A' must follow the 'str
uct' keyword [enabled by default]
xnamath.h:541:30: warning: attribute ignored in declaration of 'struct XMFLOAT3A
' [enabled by default]
Last edited on
I don't think MinGW supports Directx SDK at all. Please use Visual Studio or find a older directx port which works on mingw.
Topic archived. No new replies allowed.