srajeshnkl
srajeshnkl

Reputation: 905

Which version of C++ am I using?

Currently I am using C++ in Windows environment. I am using Visual Studio 2008 with Service pack 1.

I never thought about C++ version unless until I came to know about C++11. There appear to be different versions like ANSI standard, C++ 98 Standard etc.

  1. How do I get to know which version of C++ am I using?

  2. If I don't have Visual Studio I know I can use other Compilers like TC to compile my C++ code. In that case how can I get to know which version of C++ the compiler is using.

  3. Are the changes made in consecutive C++ versions about Programming concepts or only in Language design?

Upvotes: 12

Views: 13054

Answers (2)

Neil Kirk
Neil Kirk

Reputation: 21813

Visual Studio 2008? You can forget C++11. Visual Studio 2010 has some C++11 but it's buggy. Visual Studio 2012 has better C++11 for some features, but others are missing. Visual Studio 2013 has new support for variadic templates and other features. But VS is behind other compilers such as gcc in C++11 support. You can download free express editions for all these versions.

Upvotes: 1

Nicol Bolas
Nicol Bolas

Reputation: 474426

It's not as simple as a version check.

Every compiler that supports some C++11 supports a different subset of C++11. No compiler advertises full compliance with C++11 yet, for obvious reasons.

The C++11 specification requires that a predefined macro, __cplusplus be defined which has the value 201103L. However, you cannot rely on this macro alone. Not in real code.

You instead have to rely on compiler-specific macros to tell when compiler and which version of that compiler you're using. Or you can use Boost.Config to help you detect whether specific features are supported.

Upvotes: 9

Related Questions