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

31,447

Solution 1

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.

Solution 2

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(...)

Share:
31,447
Zeno
Author by

Zeno

Updated on September 21, 2020

Comments

  • Zeno
    Zeno over 3 years
    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.