什么是“声明中的明确资格”?错误信息是什么意思? [英] What does the "explicit qualification in declaration" error message mean?
问题描述
battleutils.cpp:1037:错误:声明为'int32 Battleutils :: AbilityBenediction(CBattleEntity *,CBattleEntity *)'
此错误的确切含义是什么?
此处的第一行是1037(在Battleutils.cpp中):
int32 Battleutils :: AbilityBenediction(CBattleEntity * PCaster,CBattleEntity * PTarget)
{
....
return blah;
}
在下面的头文件中:
namespace Battleutils
{
这是
int32 AbilityBenediction(CBattleEntity * PCaster,CBattleEntity * PTarget);
.cpp文件正确包含头文件。
tl; dr:将名称空间从函数名称之前删除。
我遇到了同样的问题。我有一些使用MS Visual Studio编译的源,但是在Linux中使用g ++却给了我:
...错误:声明' ...
当实现已经在 namespace foospace {中时,就会出现此错误。 ..}
,该实现再次为命名空间提供 int foospace :: barfunction(int blah){return 17;}
。
基本上,如果实现(.cpp文件中的代码)已经在 namespace foospace {...}
内部,则删除 foospace ::
从函数定义开始。
battleutils.cpp:1037: error: explicit qualification in declaration of 'int32 battleutils::AbilityBenediction(CBattleEntity*, CBattleEntity*)'
What does this error mean exactly?
The first line here is 1037 (in battleutils.cpp):
int32 battleutils::AbilityBenediction(CBattleEntity* PCaster, CBattleEntity* PTarget)
{
....
return blah;
}
In the header file under:
namespace battleutils
{
is this:
int32 AbilityBenediction(CBattleEntity* PCaster, CBattleEntity* PTarget);
The .cpp file correctly includes the header file.
tl;dr: Drop the namespace from before the function name.
I ran into the same issue. I had some source that compiled using MS Visual Studio but using g++ in Linux it gave me:
... error: explicit qualification in declaration of '...
It appears that this error occurs when the implementation is already inside namespace foospace {...}
and the implementation gives the namespace again int foospace::barfunction(int blah){return 17;}
.
Basically, if the implementation (the code in you .cpp file) is already inside namespace foospace {...}
then remove foospace::
from the function definition.
这篇关于什么是“声明中的明确资格”?错误信息是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!