无法在VC ++中编译头文件

时间:2022-06-02 19:49:21

I just reorganized the code for a project and now I'm getting errors I can't resolve. This header is included by a .cpp file trying to compile.

我刚刚重新组织了一个项目的代码,现在我遇到了无法解决的错误。此标头包含在尝试编译的.cpp文件中。

#include "WinMain.h"
#include "numDefs.h"
#include <bitset>

class Entity
{
public:
    Entity();
    virtual ~Entity();

    virtual bitset<MAX_SPRITE_PIXELS> getBitMask();
    virtual void getMapSection(float x, float y, int w, int h, bitset<MAX_SPRITE_PIXELS>* section);
};

I'm getting these compiler errors for the declaration of Entity::getBitMask():

我为Entity :: getBitMask()的声明得到了这些编译器错误:

error C2143: syntax error : missing ';' before '<'

错误C2143:语法错误:缺少';'在'<'之前

error C2433: 'Entity::bitset' : 'virtual' not permitted on data declarations

错误C2433:'Entity :: bitset':数据声明中不允许'virtual'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

错误C4430:缺少类型说明符 - 假定为int。注意:C ++不支持default-int

error C2238: unexpected token(s) preceding ';'

错误C2238:';'之前的意外标记

There are more similar errors for the next line as well. It seems like bitset isn't getting included but it clearly is? I can't figure out what's going wrong. WinMain.h includes windows.h, and numDefs.h includes nothing.

下一行也有更多类似的错误。似乎bitset没有被包括但显然是?我无法弄清楚出了什么问题。 WinMain.h包含windows.h,numDefs.h不包含任何内容。

Using MS Visual C++ 2008.

使用MS Visual C ++ 2008。

4 个解决方案

#1


Declare the bitset as std::bitset<MAX_SPRITE_PIXELS>.

将bitset声明为std :: bitset

#2


The bitset template is defined in the std:: namespace, so you either need to reference it by it's full name std::bitset or add using namespace std; somewhere before the class declaration.

bitset模板在std :: namespace中定义,因此您需要通过它的全名std :: bitset引用它或使用namespace std添加;在课堂宣言之前的某个地方。

#3


I think you need to say std::bitset.

我想你需要说std :: bitset。

#4


Looks like an error in "numDefs.h"

看起来像“numDefs.h”中的错误

#1


Declare the bitset as std::bitset<MAX_SPRITE_PIXELS>.

将bitset声明为std :: bitset

#2


The bitset template is defined in the std:: namespace, so you either need to reference it by it's full name std::bitset or add using namespace std; somewhere before the class declaration.

bitset模板在std :: namespace中定义,因此您需要通过它的全名std :: bitset引用它或使用namespace std添加;在课堂宣言之前的某个地方。

#3


I think you need to say std::bitset.

我想你需要说std :: bitset。

#4


Looks like an error in "numDefs.h"

看起来像“numDefs.h”中的错误