Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "explicit qualification in declaration" error message mean?

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.

like image 202
Zeno Avatar asked Dec 11 '11 03:12

Zeno


2 Answers

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.

like image 127
Benrobot Avatar answered Sep 20 '22 20:09

Benrobot


Well, this is not an answer to this particular question, but because this is the first result on Google search when searching this error message, I just might tell that I got this error message when I had declared twice the namespace (when not needed) - like this

error: explicit qualification in declaration of ...

namespace foo {      // REMOVE THIS "foo::" from here     void foo::myFunction(int x) {         // ...     }  } 

It's either missing, multiple times declared or wrong namespace. Coming from other programming languages where namespace system is used a little bit differently, I can see why it is easy to get confused since C++'s classes need to have the classes name defined like this myClass::myMemberFunction(...)

like image 23
O-9 Avatar answered Sep 19 '22 20:09

O-9