How to get the C++ version

Hi

Currenlty the New version of C++ is C++11. But I want to know which version of C++ that I'm using in my machine(Unix & windows).

How to know the correct version of C++ that I'm using.???


thanks
Vijay

Well, you could try running the ide, (otherwise known as the compiler program you're using to create your C++ programs), and check for an "About" section in the top menu. That should tell you the name of the program, the version date and even the build date.
Compiler's usually come with some sort of documentation. Maybe reading it would be appropriate.
1
2
3
Currenlty the New version of C++ is C++11. But I want to know which version of C++ that I'm using in my machine(Unix & windows).
 
How to know the correct version of C++ that I'm using.???

Note that C++11 is not a version. It a newer (enhanced) standard of C++. As such C++ will not have version, C++ will have specifications (aka standard, C99, C++11 etc)

C++ compilers will have versions. A single version of C++ compiler can support many C++ standards.

Find out the version of compiler you are using.? (cpp --version / g++ --version / cl). Once you find the version of compiler, get to the documentaion of compiler and see what all standards it supports. (as cire already posted)
Last edited on
Also you can use one compiler to compile different spec code. g++ has a parameters, which tells it which standart to adhere for example. So if you have C++11 code using newest additions and C++ code which invalid in C++11 then you can tell compiler to use specific standart. As posted before: read compiler documentation.
1
2
3
if( __cplusplus == 201103L ) std::cout << "C++11\n" ;
else if( __cplusplus == 19971L ) std::cout << "C++98\n" ;
else std::cout << "pre-standard C++\n" ;

@JLBorges
1
2
3
if( __cplusplus == 201103L ) std::cout << "C++11\n" ;
else if( __cplusplus == 199711L ) std::cout << "C++98\n" ;
else std::cout << "pre-standard C++\n" ;
I think the the second version should be "199711L"
Right. Thanks, Peter and Santosh Reddy.
Topic archived. No new replies allowed.