sclee1
sclee1

Reputation: 1281

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?

Upvotes: 3

Views: 236

Answers (1)

SomeWittyUsername
SomeWittyUsername

Reputation: 18348

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.

Upvotes: 2

Related Questions