I'm using the gcc compiler on Windows with MinGW. Version is 4.9.3. The following code gives errors when -std=c++98, -std=c++03 or -std=c++11 is used as an argument.
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
The code compiles with no errors when -std=gnu++98, -std=gnu++03 or std=gnu++11 is used as an argument. Also, the code compiles with no errors when using no c++ version arguments (g++ test.cpp -c)
On further investigation I found it was the #include causing issues. This code produces no errors when using any of the std=c++ arguments:
int main()
{
return 0;
}
However, when looking for other things to include to test my code, the following works:
#include <cmath>
int main()
{
return 0;
}
but this doesn't:
#include <string>
int main()
{
return 0;
}
What's going on? From a brief search on gnu++, it says that it provides additional extensions but code as simple as the ones above surely shouldn't be reliant on any extensions?
I've pasted the large error which occurs when compiling the first piece of code with g++ test.cpp -c -std=c++11. http://pastebin.com/k0RLtWQz
The first messages are:
$ g++ test.cpp -c -std=c++11
In file included from c:\mingw\include\wchar.h:208:0,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\cwchar:44,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\postypes.h:40,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iosfwd:40,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iostream:39,
from test.cpp:1:
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type
struct _stat __struct_stat_defined( _off_t, time_t );
^
c:\mingw\include\sys/stat.h:173:14: error: '_ino_t' does not name a type
struct _stat __struct_stat_defined( _off_t, time_t );
^
…