C++C++11C++14C++17C++20

How To Use C++ Standards In C++ Compiler Options

How To Use C++ Standards In C++ Compiler Options

C++ is a very decent programming language that has a very strong compiler supported by a big community on a range of different platforms. The C++ language definitions, syntax, and functionality are organized into different standards. Those standards are usually named after the year the standard was adopted such as 1998 for C++98, 2011 for4 C++11, 2014 for C++14, and 2017 for C++17. One of the great features of a C++ compiler is you can choose which standards you want your code to be compiled against, before the compilation of your source code. This allows the compiler to check that your code complies with that standard. In this post, we explain what the standards are, how you can view them, how you can check the compatibility of your C++ source code against different standards, and how you can choose to use C++ standards in C++ compiler options.

What is a C++ standard?

Standards are an international agreement for C++ compilers, made by the IDE and compiler developers of different operating systems (Embarcadero C++ Builder, Microsoft MSVC, GNU GCC, Apple Swift, etc.). They are formal, legal, and very high-level detailed technical documents intended primarily for people writing C++ compilers and standard library implementations. 

The current available standards and some of their key features are listed below.

How To Use C++ Standards In C++ Compiler Options A schematic diagram of the C++ standards

How to use C++ standards in C++ compiler options?

When we use '-std=' option in a C++ compiler this option type enables or disables some features. We need to use these features to see the effect of each C++ standard option.

Personally, I always prefer to use the latest version of the standards in my compilers. However, when programming, sometimes you may have to work on old or legacy C++ source, or you may be programming to another company that uses older standard compilers. Or maybe you just want to check if your code is compatible with a particular standard, or the code uses new standards. At these times, you can use std option in C++ compilers.

In general, we can use the -std option to compile to a particular C++ standard. Here are some option examples,

  • -std=c++98
  • -std=c++11
  • -std=c++14
  • -std=c++17
  • -std=c++20 or -std=c++2a

For example, if you want to compile your code with C++11 features, you can use C++ Builder 64bits command line compiler as shown below:

For an example, we can write this C++ code below which uses a feature found in the C++17 standard and above.

If you are using the C++17 compiler, this code will be compiled successfully because the static_assert feature comes with C++17. If you compile this code with -std=c++11 or -std=c++14 options this time you will get warning which is telling you that you have requested C++ standard version 11, but there is a feature that requires C++ standard version 17 (Until C++17, a message was required w/ static_assert).

How to use C++ standards in the C++ Builder compiler options?

In C++ Builder CLANG compiler, we can use -std option to compile in previous standards. This option can be used in bcc32c and bcc64, both support these std options below,

  • -std=c++11
  • -std=c++14
  • -std=c++17

I should note that, C++11 and C++14 options are partially supported, these options do not have a STL that works with all, so you have the latest STL one for C++17. According to the bcc32c and bcc64 compilers, these all std options below are supported ‘partially’.

  • -std=c++98 or -std=c++03 for ‘ISO C++ 1998 with amendments’ standard
  • -std=gnu++98 or -std=gnu++03 for ‘ISO C++ 1998 with amendments and GNU extensions’ standard
  • -std=c++11 for ‘ISO C++ 2011 with amendments’ standard
  • -std=gnu++11 for ‘ISO C++ 2011 with amendments and GNU extensions’ standard
  • -std=c++14 for ‘ISO C++ 2014 with amendments’ standard
  • -std=gnu++14 for ‘ISO C++ 2014 with amendments and GNU extensions’ standard
  • -std=c++17 for ‘ISO C++ 2017 with amendments’ standard
  • -std=gnu++17 for ‘ISO C++ 2017 with amendments and GNU extensions’ standard

For example, if you want to compile your codes with C++11 features and below, you can use C++ Builder CLANG compiler as below,

or you can use 64bits C++ Builder compiler as below,

Here are all of my tests with some simple C++ code:

How to use C++ standards in GNU C++ compiler options?

In GNU gcc / g++ compiler, we can use the -std option to compile to various C++ standards.

  • -std=c++98
  • -std=c++11
  • -std=c++14
  • -std=c++17
  • -std=c++20 or -std=c++2a

For example, if you have C++17 compiler, you can compile the myapp.cpp file using the C++11 standards as shown below:

How to use C++ standards in MSVC compiler options?

According to Microsoft , these are the standard options that can be used as below. More information can be found here document here.

  • /std:c++14
  • /std:c++17
  • /std:c++20
  • /std:c++latest
  • /std:c11
  • /std:c17

How to use C++ standards in CLANG compiler options?

In CLANG clang++ compiler, we can use the -std option to compile to specific C++ standards as shown below.

  • -std=c++98
  • -std=c++11
  • -std=c++14
  • -std=c++17
  • -std=c++20


For example, if you have C++17 compiler, you can compile myapp.cpp file using the rules of the C++14 standard as shown below.

How To Use C++ Standards In C++ Compiler Options The C++ Builder logo

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise version.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
Artificial Intelligence TechC++C++17C++20Learn C++

How To Create Simple Generative AI Code In C++

C++C++17Language FeatureLearn C++

How To Use The SVG Image Format With Skia In C++ Builder

C++C++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?