Jump to content

  • Log In with Google      Sign In   
  • Create Account

hundreds of errors and warnings in xnamath.h


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Nick C.   Members   -  Reputation: 192

Like
0Likes
Like

Posted 29 November 2012 - 05:17 PM

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 Posted Image )


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]

Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1530

Like
1Likes
Like

Posted 29 November 2012 - 06:26 PM

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.

#3 Nick C.   Members   -  Reputation: 192

Like
0Likes
Like

Posted 29 November 2012 - 06:41 PM

"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.

#4 Erik Rufelt   Crossbones+   -  Reputation: 3480

Like
2Likes
Like

Posted 29 November 2012 - 07:02 PM

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.

#5 Nick C.   Members   -  Reputation: 192

Like
0Likes
Like

Posted 30 November 2012 - 12:37 PM

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

#6 AdeptStrain   Members   -  Reputation: 342

Like
1Likes
Like

Posted 03 December 2012 - 10:18 AM

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


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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS