Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to determine the version of the C++ standard used by the compiler?


1 Answer
Samual Sam

Sometimes we need to know that, what is the current C++ standard. To get this kind of information, we can use the macro called __cplusplus. For different standards, the value of this will be like below.

Standard__cplusplus output
C++ pre C++98
1
C++98
199711L
C++98 + TR1
This cannot be checked, this will be marked as C++98
C++11
201103L
C++14
201402L
C++17
201703L

Example

#include<iostream>
int main() {
   if (__cplusplus == 201703L)
      std::cout << "C++17" << endl;
   else if (__cplusplus == 201402L)
      std::cout << "C++14" << endl;
   else if (__cplusplus == 201103L)
      std::cout << "C++11" << endl;
   else if (__cplusplus == 199711L)
      std::cout << "C++98" << endl;
   else
      std::cout << "pre-standard C++" << endl;
}

Output

C++98

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.