sclee1 sclee1 - 15 days ago 4x
C++ Question

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
. However, I don't think that my C++ standard is
because I can use
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?


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.