Jump to content
  • Advertisement
Sign in to follow this  
Nick C.

hundreds of errors and warnings in xnamath.h

This topic is 2052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!