hundreds of errors and warnings in xnamath.h

Started by
4 comments, last by AdeptStrain 11 years, 4 months ago
Hello everyone.
I'm getting hundreds of errors (251 to be precise) in the file xnamath.h. I'm not going to show them all, because that wouldn't make sense. The file is fine, and I can use it perfectly in other projects. It's hard to find the cause of a problem if visual studio shows errors which are not wrong. I got this problem when creating the following class (pretty simple, so I don't see how this would cause any problems). Thanks in advance. (btw, I'm pretty sure this belongs to general programming. If not, sorry about that unsure.png )


ModelInstance.cpp:

[source lang="cpp"]#include "ModelInstance.h"


ModelInstance::ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset) :
Scale(scale), Rot(rot), Offset(offset), Scale2(XMFLOAT3(1.0f, 1.0f, 1.0f)), Rot2(XMFLOAT3(0, 0, 0)), Offset2(XMFLOAT3(0, 0, 0))
{
}


ModelInstance::~ModelInstance()
{
}

void Modelinstance::Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset)
{
Scale2 = scale; Rot2 = rot; Offset2 = offset;
}
XMFLOAT4X4 Modelinstance::World()
{
XMFLOAT4X4 worldTransform;
XMStoreFloat4x4(&worldTransform,
XMMatrixScaling(Scale.x, Scale.y, Scale.z) *
(XMMatrixRotationX(Rot.x) * XMMatrixRotationY(Rot.y) * XMMatrixRotationZ(Rot.z)) *
XMMatrixTranslation(Offset.x, Offset.y, Offset.z) *
XMMatrixScaling(Scale2.x, Scale2.y, Scale2.z) *
(XMMatrixRotationX(Rot2.x) * XMMatrixRotationY(Rot2.y) * XMMatrixRotationZ(Rot2.z)) *
XMMatrixTranslation(Offset2.x, Offset2.y, Offset2.z));
return worldTransform;
}
[/source]


ModelInstance.h:

[source lang="cpp"]#ifndef MODELINSTANCE_H
#define MODELINSTANCE_H
#include <xnamath.h>

struct ModelInstance
{
public:
ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset);
virtual ~ModelInstance();

virtual void Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset);
XMFLOAT4X4 World();

protected:
XMFLOAT3 Scale, Scale2;
XMFLOAT3 Rot, Rot2;
XMFLOAT3 Offset, Offset2;
};
#endif
[/source]
Advertisement

I'm getting hundreds of errors (251 to be precise) in the file xnamath.h. I'm not going to show them all, because that wouldn't make sense.


Could you show one of the errors? How about the first one in the list of errors, that usually makes sense.
"Error 1 error C2146: syntax error : missing ';' before identifier 'XMConvertToRadians' c:\program files (x86)\microsoft directx sdk (june 2010)\include\xnamath.h 159"

and code in xnamath.h:

//...code

#define XM_CRMASK_CR6BOUNDS XM_CRMASK_CR6FALSE
#define XM_CACHE_LINE_SIZE 64
/****************************************************************************
*
* Macros
*
****************************************************************************/
// Unit conversion
XMFINLINE FLOAT XMConvertToRadians(FLOAT fDegrees) { return fDegrees * (XM_PI / 180.0f); }

//...code

The weird thing is, I don't have any problems using xnamath in other classes. I only get these errors when including it in this class (at "#include <xnamath.h>"). My project worked perfectly before the creation of this class.
Try including Windows.h or some DirectX files first. Perhaps it's dependent on 'FLOAT' for example which isn't defined in this file or similar.
Solved! :)
I had to #include <d3dx11.h> first.
1 rep for Erik! :)

Solved! smile.png
I had to #include <d3dx11.h> first.
1 rep for Erik! smile.png


You don't actually need <d3dx11.h>, just <windows.h> - as Eric mentioned above. XNAMath isn't DX11 specific.

This topic is closed to new replies.

Advertisement