GCC documentation says
-ansi
In C mode, this is equivalent to -std=c90. In C++ mode, it is equivalent to -std=c++98.
So, this is
g++ -ansi -std=c++0x ...
equivalent to
g++ -std=c++98 -std=c++0x ...
When you compile it with
g++ -ansi -std=c++0x ...
I believe, it's equivalent to not specifying -ansi
at all, due to the command line parsing which usually takes the last argument for a given parameter. This is speculation though. But I tested with a simple program:
#include<iostream>
constexpr int value() {return 42;}
int main(void)
{
std::cout<<value()<<std::endl;
}
This program can't compile in C++98 as constexpr
was introduced in C++11. But it compiles fine with both:
g++ -ansi -std=c++11 test.cpp
and
g++ -ansi -std=c++98 -std=c++11 t.cpp
But fails with both:
g++ -ansi -std=c++11 -ansi test.cpp
and
g++ -ansi -std=c++11 -std=c++98 t.cpp
Giving the errors:
error: ‘constexpr’ does not name a type
note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
This suggests whatever the specified as the last -std
is only one effective and you might as well remove the -ansi
.