Search code examples
c++iostreamexplicit

explicit qualification in declaration of 'std::cout'


The problem is really strange for me.

The code is as simple as possible:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

It is just helloworld as it is created from standart cpp project. I am sure it was worked. But after some time (really don't remember what have chaged...) I got an error:

error: explicit qualification in declaration of 'std::cout'
   extern ostream std::cout;  /// Linked to standard output

funny thing that is not in the project but inside iostream

some help? ^_^

.new information.: I was building boost library and for many of files I am getting the same error: explicit qualification in declaration of 'std::cout'

I use MinGW


Solution

  • The only explanations that come to mind are:

    1. Someone modified the standard header (accidentally?), replacing the original

      extern ostream cout;
      

      with incorrect

      extern ostream std::cout;
      
    2. Someone defined a macro named cout as std::cout, most likely in the compiler's command line. E.g.

      -Dcout=std::cout
      

      See http://coliru.stacked-crooked.com/a/bc5be8c7d99fed53 for example.