C++ 尽管命名空间正确,但缺少类型说明符
如果忘记将C++ 尽管命名空间正确,但缺少类型说明符,c++,types,namespaces,directx,specifier,C++,Types,Namespaces,Directx,Specifier,如果忘记将std::添加到像string这样的对象,我通常会看到一个错误。在本例中,它是我自己的名称空间,称为x。具体错误如下: 错误59错误C2143:语法错误:缺少“;”在“*”之前e:\cppworkspace\xengine\xengine\code\include\x\graphics\graphics.h 32 1 xengine 错误60错误C4430:缺少类型说明符-假定为int。注意:C++不支持缺省INT:E\CPPWorkStudio\xMex\xEng\\Calp\\\x
std::
添加到像string
这样的对象,我通常会看到一个错误。在本例中,它是我自己的名称空间
,称为x
。具体错误如下:
错误59错误C2143:语法错误:缺少“;”在“*”之前e:\cppworkspace\xengine\xengine\code\include\x\graphics\graphics.h 32 1 xengine
错误60错误C4430:缺少类型说明符-假定为int。注意:C++不支持缺省INT:E\CPPWorkStudio\xMex\xEng\\Calp\\\x\Case\Casic。h 32 1 xEng/<代码> < /P>
图形头文件:
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "x/x.h"
#include "x/graphics/d3dwrapper.h"
namespace x
{
class Graphics
{
public:
Graphics() {}
~Graphics(){}
bool Init(int32 width, int32 height, bool fullscreen, HWND hwnd);
void Destroy();
void Update();
void Render();
protected:
private:
Graphics(const Graphics& other) {}
D3DWrapper* m_d3d; // ERROR IS HERE
};
}
#endif // GRAPHICS_H
#ifndef D3DWRAPPER_H
#define D3DWRAPPER_H
#include "x/x.h"
#include "x/system/system.h"
namespace x
{
class D3DWrapper
{
public:
D3DWrapper();
~D3DWrapper() {}
bool Init(int32 width, int32 height, bool fullscreen, HWND hwnd);
void Release();
bool InitScene();
void BeginScene(Color color);
void EndScene();
inline ID3D11Device* GetDevice() { return m_device; }
inline ID3D11DeviceContext* GetDeviceContext() { return m_deviceContext; }
protected:
private:
D3DWrapper(const D3DWrapper& other) {}
ID3D11Device* m_device;
ID3D11DeviceContext* m_deviceContext;
IDXGISwapChain* m_swapChain;
ID3D11RenderTargetView* m_renderTargetView;
};
}
#endif // D3DWRAPPER_H
D3DWrapper头文件:
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "x/x.h"
#include "x/graphics/d3dwrapper.h"
namespace x
{
class Graphics
{
public:
Graphics() {}
~Graphics(){}
bool Init(int32 width, int32 height, bool fullscreen, HWND hwnd);
void Destroy();
void Update();
void Render();
protected:
private:
Graphics(const Graphics& other) {}
D3DWrapper* m_d3d; // ERROR IS HERE
};
}
#endif // GRAPHICS_H
#ifndef D3DWRAPPER_H
#define D3DWRAPPER_H
#include "x/x.h"
#include "x/system/system.h"
namespace x
{
class D3DWrapper
{
public:
D3DWrapper();
~D3DWrapper() {}
bool Init(int32 width, int32 height, bool fullscreen, HWND hwnd);
void Release();
bool InitScene();
void BeginScene(Color color);
void EndScene();
inline ID3D11Device* GetDevice() { return m_device; }
inline ID3D11DeviceContext* GetDeviceContext() { return m_deviceContext; }
protected:
private:
D3DWrapper(const D3DWrapper& other) {}
ID3D11Device* m_device;
ID3D11DeviceContext* m_deviceContext;
IDXGISwapChain* m_swapChain;
ID3D11RenderTargetView* m_renderTargetView;
};
}
#endif // D3DWRAPPER_H
我似乎无法找出我的代码中可能出现的错误,因此非常感谢您的帮助。x.h中是否有可能包含上述两个文件之一的include?你的(复制)构造函数有一个空的主体是故意的吗?你能不能给我们一个线索,哪两行产生了这些错误?这就是错误消息有行号的原因。@PeteBecker我的错误,我将编辑问题,但图形标题代码中的D3DWrapper*m_d3d
行似乎是正确的。名称空间应该没有任何问题。我注意到的唯一一件事是,你有一个x/x.h的双重包含,因为你的D3DWrapper已经包含了它(可能你没有ifndef声明)@kaiser我删除了双重包含,但这没有帮助。我开始想这是一个问题,我的系统如何。h,因为它包括图形,其中包括d3dwrapper?我会试着在课后玩这个