Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the C++ standard version Visual Studio uses

I am using Visual Studio 2015 for my programming tasks, and I was wondering what version of the C++ standard the compiler used.

Googling didn't result in anything.

I tested those conditions, but they don't work properly:

if (__cplusplus == 201103L) std::cout << "C++11\n";
else if (__cplusplus == 201402L) std::cout << "C+14\n";
else if (__cplusplus == 19971L) std::cout << "C++98\n";
else std::cout << "pre-standard C++\n";

The output is pre-standard. However, I don't think that my C++ standard is pre-standard because I can use auto when specifying a type, which can only be used in C++11.

So, is there any easy way to get the C++ standard in Visual Studio?

like image 947
sclee1 Avatar asked Sep 03 '26 19:09

sclee1


1 Answers

You have a typo in else if (__cplusplus == 19971L) std::cout << "C++98\n";. It should be else if (__cplusplus == 199711L) std::cout << "C++98\n";.

This is still the version in VS2015, probably because it still doesn't support the standard to the full extent.

like image 186
SomeWittyUsername Avatar answered Sep 06 '26 09:09

SomeWittyUsername