Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 300
Rajesh Subramanian Avatar asked Feb 15 '12 03:02

Rajesh Subramanian


People also ask

What version of C should I use?

The right language to program in, for many applications, would be the superset of pre-Standard C, C89, C99, and C11. It's important, however, that anyone programming in that language be clear that they're using that language rather than a shrinking subset which favors speed over reliability. Save this answer.

What version of C does GCC use?

GCC supports Objective-C++ and features available in Objective-C are also available in Objective-C++. GCC by default uses the GNU Objective-C runtime library, which is part of GCC and is not the same as the Apple/NeXT Objective-C runtime library used on Apple systems.

Are C versions different?

Let's continue with a discussion of all the five different standards of C — K&R C, ANSI C, C99, C11 and Embedded C. For the purposes of our discussion, the compiler used is the gcc C compiler from the GNU Compiler Collection (GCC).


1 Answers

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.

like image 158
Nicol Bolas Avatar answered Oct 10 '22 02:10

Nicol Bolas