我在头文件中遇到了常见的错误,如下所示。
Error 54 error C3083: 'Resources': the symbol to the left of a '::' must be a type e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 28 1 DX2DHelper
Error 55 error C2039: 'DX2DImage' : is not a member of 'DX2DHelper' e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 28 1 DX2DHelper
Error 56 error C2061: syntax error : identifier 'DX2DImage' e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 28 1 DX2DHelper
Error 57 error C3083: 'Resources': the symbol to the left of a '::' must be a type e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 32 1 DX2DHelper
Error 58 error C2039: 'DX2DImage' : is not a member of 'DX2DHelper' e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 32 1 DX2DHelper
Error 59 error C2143: syntax error : missing ';' before '*' e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 32 1 DX2DHelper
Error 60 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\sprite.h 32 1 DX2DHelper
Error 61 error C2061: syntax error : identifier 'GameBase' e:\users\nkosi\documents\visual studio 2010\projects\directx games\direct2d\dx2dhelper\dx2dhelper\systemclass.h 30 1 DX2DHelper
但是,对于我的一生,我无法弄清楚我做错了什么。我知道我可能错过了一个分号或其他东西,但我真的想不通。所有头文件都在下面。
DX2DHelper.h
#include "targetver.h"
#define WIN32_LEAN_AND_MEANheaders
// Windows Header Files:
#include <windows.h>
#include <iostream>
#include <D2D1.h>
#include <D2D1Helper.h>
#include <wincodec.h>
#include <D2DBaseTypes.h>
#include <D2Derr.h>
#define DLEX __declspec(dllexport)
#include "GameBase.h"
#include "SystemClass.h"
#include "DX2DImage.h"
#include "Sprite.h"
系统类.h
#ifndef SYSTEMCLASS_H
#define SYSTEMCLASS_H
#include "DX2DHelper.h"
namespace DX2DHelper
{
namespace Core
{
class SystemClass;
struct WindowOptions;
struct DLEX WindowOptions {};
class DLEX SystemClass
{
public:
bool Initialize(WindowOptions options, HINSTANCE hInst);
void Run(GameBase* game, DX2DInitOptions options);
private:
WindowOptions options;
};
}
}
#endif
DX2DImage.h
#ifndef DX2DIMAGE_H
#define DX2DIMAGE_H
#include "DX2DHelper.h"
namespace DX2DHelper
{
namespace Resources
{
class DX2DImage;
class DX2DImageLoader;
class DLEX DX2DImageLoader
{
public:
HRESULT LoadFromFile(char* filePath, DX2DImage* image);
};
class DLEX DX2DImage
{
public:
friend class DX2DImageLoader;
};
}
}
#endif
精灵.h
#ifndef SPRITE_H
#define SPRITE_H
#include "DX2DHelper.h"
namespace DX2DHelper
{
namespace GameComponents
{
class DLEX Sprite
{
public:
void SetImage(DX2DHelper::Resources::DX2DImage* image);
private:
DX2DHelper::Resources::DX2DImage* image;
};
}
}
#endif
游戏基础.h
#ifndef GAMEBASE_H
#define GAMEBASE_H
#include "DX2DHelper.h"
namespace DX2DHelper
{
namespace Core
{
class DLEX GameBase
{
public:
friend class SystemClass;
HRESULT Initialize(HINSTANCE hInst, HWND winHandle, struct DX2DInitOptions options);
};
struct DLEX DX2DInitOptions {};
}
}
#endif
如果有人能找出错误,我将不胜感激。我一直在查看相同的文件可能将近一个小时,一个半小时,但我无法修复它。