I'm making a DirectX11 App in Visual Studio 2017 using C++, I need to declare a data structure in my "GeometryGenerator.h" header file.
The problem is that when I try to use the types: XMFLOAT3 in my header file I got an error from Visual Studio when I try to run the project and gives me this message:
“C4430: missing type specifier - int assumed”
In the lines where I declare variables of type XMFLOAT3
This is my code:
#pragma once
#include "..\Common\DeviceResources.h"
#include "ShaderStructures.h"
#include "..\Common\StepTimer.h"
namespace DirectX11Engine
{
class GeometryGenerator {
public:
struct Vertex
{
Vertex() {}
Vertex(const XMFLOAT3& p, const XMFLOAT3& n, const XMFLOAT3& t, const XMFLOAT2& uv)
: Position(p), Normal(n), TangentU(t), TexC(uv) {}
Vertex(
float px, float py, float pz,
float nx, float ny, float nz,
float tx, float ty, float tz,
float u, float v)
: Position(px, py, pz), Normal(nx, ny, nz),
TangentU(tx, ty, tz), TexC(u, v) {}
XMFLOAT3 Position;
XMFLOAT3 Normal;
XMFLOAT3 TangentU;
XMFLOAT2 TexC;
};
void PruebaDeTipos();
};
}
If I add this:
using namespace DirectX;
I get rid of the problem. My question is whether using namespaces X
in header files a bad and dangerous practice in C++? And also how then can I use types declared in their own namespaces inside .cpp files?