
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
How to determine the version of the C++ standard used by the compiler?
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
- Related Articles
- Java Program to determine the name and version of the operating system
- Haskell Program to determine the name and version of the operating system
- How to install the specific version of the PowerShell module version?
- How can I determine the connection method used by a MySQL Client?
- How to check the system version of Android?
- Which radioactive isotope is used to determine the activity of thyroid gland?
- How to divide the matrix rows by row standard deviation in R?
- How can Tensorflow be used with pre-trained model to determine the number of batches in the dataset?
- How do you determine which backend is being used by matplotlib?
- How to find the version of Java using command line?
- How to specify the URL of the resource to be used by the object in HTML?
- How to divide the data frame rows in R by row standard deviation?
- How to divide the data.table object rows by row standard deviation in R?
- How to change the TLS version in PowerShell?
- How to install the latest PowerShell module version?

Advertisements