vendredi 16 avril 2021

warning: 'auto' type specifier is a C++11 extension

I have a very simple C++ code statement auto a = 12;.

When I am compiling it with g++ in Linux using -std=c++98 option I am getting an error as expected

error: ‘a’ does not name a type

But when I am compiling the same code with the same option in MacOS I am getting just a warning, but the code get's compiled fine.

warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]

But wasn't the whole point of -std=c++98 to compile the code following C++ 98 standards? So the warning tells even though auto is a C++11 extension I am going to compile it for you?

Is there any option to force using c++98 (or other standard)?

g++ --version prints Apple clang version 12.0.0 (clang-1200.0.32.29) which is another weird thing by the way. So it is clang actually.

It's like asking firefox --version and getting chrome 87.0.4280.163

Aucun commentaire:

Enregistrer un commentaire