How to get the C++ version

Jan 23, 2013 at 5:16am
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

Jan 23, 2013 at 6:01am
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.
Jan 23, 2013 at 6:42am
Compiler's usually come with some sort of documentation. Maybe reading it would be appropriate.
Jan 23, 2013 at 8:54am
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 Jan 23, 2013 at 8:55am
Jan 23, 2013 at 11:37am
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.
Jan 23, 2013 at 2:13pm
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" ;

Jan 23, 2013 at 2:23pm
@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" ;
Jan 23, 2013 at 2:30pm
I think the the second version should be "199711L"
Jan 23, 2013 at 3:05pm
Right. Thanks, Peter and Santosh Reddy.
Topic archived. No new replies allowed.