0.12 — Configuring your compiler: Choosing a language standard

With many different versions of C++ available (C++98, C++03, C++11, C++14, C++17, C++20, etc…) how does your compiler know which one to use? Generally, a compiler will pick a standard to default to (typically not the most recent language standard).

If you wish to use a different language standard (and you probably will), you’ll have to configure your IDE/compiler to do so.

Code names for in-progress language standards

Finalized language standards are named after the years in which they are finalized (e.g. C++17 was finalized in 2017).

However, when a new language standard is being agreed upon, it’s not clear in what year the finalization will take place. Consequently, in-progress language standards are given code names, which are then replaced by the actual names upon finalization of the standard. For example, C++11 was called c++1x while it was being worked on. You may still see the code names used in places (especially for upcoming version of the language standard, which won’t have a final name yet).

Here’s a mapping of code names to the final names:

  • c++1x = C++11
  • c++1y = C++14
  • c++1z = C++17
  • c++2a = C++20
  • c++2b = C++23

For example, if you see c++1z, this is synonymous with the C++17 language standard.

Which language standard should you choose?

In professional environments, it’s common to choose a language standard that is one or two versions back from the latest standard (e.g. now that C++20 is out, that means C++14 or C++17). This is typically done to ensure the compiler makers have had a chance to resolve defects, and so that best practices for new features are well understood. Where relevant, this also helps ensure better cross-platform compatibility, as compilers on some platforms may not provide full support for newer language standards immediately.

For personal projects and while learning, there is little downside to choosing the latest finalized standard (as of the time of writing, currently C++20).

Author's note

This website currently targets the C++17 standard, meaning our lessons and examples assume your compiler is C++17 capable. Some C++20 content is optionally available for those with C++20 compatible compilers.

To take full advantage of all the lesson content, we recommend using the C++20 language standard if your compiler supports it. Using the C++17 language standard will also provide a good experience.

If your compiler doesn’t support C++17, we recommend upgrading to one that does. If this is not possible for some reason, you will need to skip some newer content, and alter some examples so that they will compile. This should not impact your overall experience too heavily (especially in the early lessons).

C++14 is the minimum language standard for a decent experience on this site.

There’s an example at the end of this lesson which you can use to test if you set up your compiler to use C++17 correctly.

Setting a language standard in Visual Studio

As of the time of writing, Visual Studio 2019 defaults to C++14 capabilities, which does not allow for the use of newer features introduced in C++17 and C++20.

To use these newer features, you’ll need to enable a newer language standard. Unfortunately, there is currently no way to do this globally -- you must do so on a project-by-project basis.


With Visual Studio, you will need to reselect your language standard every time you create a new project.

To select a language standard, open your project, then go to Project menu > (Your application’s Name) Properties, then open Configuration Properties > C/C++ > Language.

From there, you can set the C++ Language Standard to the version of C++ you wish to use.


We recommend choosing the latest standard “ISO C++ Latest (/std:c++latest)”, which as of the time of writing is the setting for C++20 support.

Related content

For more information on Visual Studio language standard settings, Microsoft has a Visual Studio language standard reference document.

Setting a language standard in Code::Blocks

Code::Blocks may default to a pre-C++11 language standard. You’ll definitely want to check and ensure a more modern language standard is enabled.

The good news is that Code::Blocks allows setting your language standard globally, so you can set it once (rather than per-project). To do so, go to Settings menu > Compiler…:

Code::Blocks Settings > Compiler

Then find the checkboxes labeled Have g++ follow the C++XX ISO C++ language standard [-std=c++XX], where XX is some number (e.g. 20, 17, etc…) representing a language standard:

Code::Blocks C++11 setting


If C++20 or C++17 appears in this list, select the one that represents the latest ISO standard (e.g. select Have g++ follow the C++20 ISO language standard). If you see GNU standards in this list as well, ignore them.

If you do not see C++20 or C++17 in this list, upgrade to the latest version of Code::Blocks.

If upgrading to the latest version is not possible for some reason, your version of Code::Blocks may have support for upcoming (or just released) versions of C++. If so, these will be labeled Have g++ follow the coming C++XX (aka C++YY) ISO C++ language standard [-std=c++XX] (see the blue box above). Select the latest version from this list.

Setting a language standard in g++

For GCC/G++ users

For GCC/G++, you can pass compiler flags -std=c++11, -std=c++14, -std=c++17, or -std=c++2a to enable C++11/14/17/2a support respectively.

Testing your compiler for C++17 compatibility

After enabling the C++17 language standard (or higher), you should be able to compile the following code without any warnings or errors.

If you can’t compile this code, you either haven’t enabled C++17, or your compiler doesn’t fully support C++17. In the latter case, please install the latest version of your IDE/compiler, as described in lesson 0.6 -- Installing an Integrated Development Environment (IDE).

1.1 -- Statements and the structure of a program
0.11 -- Configuring your compiler: Warning and error levels

184 comments to 0.12 — Configuring your compiler: Choosing a language standard

  • Jeni

    I've been following along using JetBrain's AppCode (because I generally use IntelliJ for most of my engineering work).  On OS X.  Having a little challenge figuring out how I can tell which versions of compilers I have available and how to either download/update to a C++17 compiler or to adjust settings to use it.  Will happily add details, if they are wanted by others, when I find out how to do this.  I laugh at myself a bit as I search for an equivalent to java -version.. I would really like to just be able to do:  'which cpp', 'cpp -version', etc.  These command line tools likely do have a parallel - I'm just not yet sure what they are.

    • Jeni

      Got it... switched to Jetbrains CLion - much better; targeted for C and C++.  Allows you to switch to use whichever compiler you choose.  In OS X, you have multiple versions of C++ available - defaults to 14 on my machine.  (not claiming this is universal - just the detail that I found.)  To test, you can run this:  

      Apparently, newer versions of XCode have different versions of cplusplus. At command line,


      do both work and yield good data.  I have read, but have not tested, that you can specify cpp version dwhen compiling and running at command line using

      . Again - I have not tested this, so please don't throw rotten tomatoes at me if that doesn't work!

  • Jon

    Codeblocks on Fedora:

    I have run

    , but I'm still missing G++ standards (my only option in the compiler settings dialog box is -std=c++98)

  • miguel luna

    So when I rune the build I get the following with nor errors

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    however I already changed the project properties to use the latest standard of C++ and the program seems to run anyways. Anyone have any idea what is going on?

  • Waldo Lemmer

    Damn, this lesson has changed so much since I last read it

  • teod

    is there any way to set C++17 as the default on VS 2019? The only answer I can find online seems to be a frustratingly poor explanation

  • Hariharan VN

    Can anyone explain
    what is this template<class...T> and this too namespace a::b::c

  • NKTn

    idk why but i got this Output from visual studio 2019:
    Build started...
    1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(787,9): error MSB4030: "Yes(/WX)" is an invalid value for the "TreatWarningAsError" parameter of the "CL" task. The "TreatWarningAsError" parameter is of type "System.Boolean".
    1>Done building project "HelloWorld.vcxproj" -- FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    with 15 errors
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error    MSB4030    "Yes(/WX)" is an invalid value for the "TreatWarningAsError" parameter of the "CL" task. The "TreatWarningAsError" parameter is of type "System.Boolean".    HelloWorld    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets    787    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0441    argument list for class template "std::array" is missing    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    24    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E1593    cannot deduce 'auto' type (initializer required)    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    21    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0065    expected a ';'    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    21    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0065    expected a ';'    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    24    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0017    expected a ']'    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    21    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0040    expected an identifier    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    21    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0028    expression must have a constant value    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    10    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0020    identifier "arr" is undefined    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    26    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0020    identifier "iNumbers" is undefined    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    21    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0325    inline specifier allowed on function declarations only    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    10    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0276    name followed by '::' must be a class or namespace name    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    22    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0135    namespace "std" has no member "string_view"    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    10    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0304    no instance of overloaded function "std::size" matches the argument list    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    26    
    -Severity    Code    Description    Project    File    Line    Suppression State
    Error (active)    E0283    qualified name is not allowed    HelloWorld    D:\C++\HelloWorld\HelloWorld.cpp    8

  • Lesommeil

    I don't know why Windows desktop Wizard just can't support C++17, but it works if I create an empty project,

    Except VS2019 is downloaded a long time ago, I can't find any problems.

    If I just use an empty project as usual it will be fine?

    So there can I ask why create the Windows desktop Wizard project. I've never used it before.

  • Mal

    In the sectiom - Setting a language standard in Visual Studio you say "To use these newer features, you’ll need to enable a newer language standard. Unfortunately, there is currently no way to do this globally -- you must do so on a project-by-project basis."

    This is only true if you always use the desktop wizard to create you project.

    What you can do use the desktop wizard to create a new project.  You then change the language to C++17 and then use the "Project" menu and then "Export template" and save it to, say "my_basic_template".  Next time you start VS2019 just pick the my_basic_template option instead of desktop wizard and your new project will start with C++17 as standard.

    Much easier than remembering to change the language every time you create a new project.

  • Manuel Calzadillas

    Nice lesson, my goal when I finish this course is to be able to do HMI with c++ that are fast and efficient but also good to look at
    Keep up the good work

  • Prashant Singh Tomar

    I am getting error in #include<string_view>
    Anyone ???

  • kirozin

    Trying out the code in Visual Studio 2019, I received fatal error c1010, which after googling found that I needed to simply add "#include <pch.h>" before any of the other header files. And when I did that, c1010 disappeared, but I still got error e1696. Am I doing something wrong?

    Edit: I turned off precompiled headers and this seems to have worked. Please let me know if this is a good fix for future issues.

  • J Nava sai krishna

    For Codeblocks users: I think even if we checked the box +20 version(latest) it gives an error. we need to swtich back to +17 version as instructed by the author
    Also It clearly gave an error where I need to fix my changes.

    "The compiler's setup (GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
      Probably the toolchain path within the compiler options is not setup correctly?!
      Do you have a compiler installed?
    Goto "Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables" and fix the compiler's setup.

    Tried to run compiler executable 'C:\Program Files\CodeBlocks\MinGW\lib\gcc/bin/gcc.exe', but failed!

    Nothing to be done (all items are up-to-date)."

    as mentioned in the error i tried to auto detect the compiler option in the tool chain executables then it got resolved. Hope anyone facing the same error can get help with this
    have a great day

  • Ivan

    I'm using Visual Studio 2015 and I don't have the option to choose language standard.And I can't compilethe codes.

  • Aarmaan

    when I tried to complie i got this

    'HelloWorld.exe' (Win32): Loaded 'C:\Users\Aarmaan\Desktop\c++ Projects\HelloWorld\Debug\HelloWorld.exe'. Symbols loaded.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'.
    The thread 0x35d8 has exited with code 0 (0x0).
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'.
    'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'.
    The thread 0x4b48 has exited with code 0 (0x0).
    The thread 0x2848 has exited with code 0 (0x0).
    The thread 0x2308 has exited with code 0 (0x0).
    The program '[6704] HelloWorld.exe' has exited with code 0 (0x0).

  • angel


    what i'm supposed to get?

  • violist

    In Linux Ubuntu you have to use g++ -std=c++17 nameofthefile.cpp to compile it and than ./a.out. If you use standard g++ nameofthefile.cpp you will get errors because standard g++ doesn't support c++17.
    If you want to automatically compile and run program let's say in sublime text, create a new build system, add this in it and save it:

       "cmd": "g++ \"${file}\" -o \"${file_path}\\\\${file_base_name}\"",
       "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
       "working_dir": "${file_path}",
       "selector": "source.c,source.c++,source.cpp",
       "variants": [
           "name": "Run",
            "cmd" : ["gnome-terminal -- bash -c \"g++ -std=c++17 $file_name; ./a.out;echo;echo;  echo Press ENTER to continue; read line;exit; exec bash\""

  • Mike

    I compiled the code, but I don't know what it means, for example "#include".
    Later on will he teach?

    • LoneWoIf

      He surely will... This code is just designed to test if your compiler is fit to compile language features from C++17. You will learn about all those language features later.

  • Cuyler

    In Visual Studio 2019 Community, should I use /std:c++17 or /std:c++latest? I know I'm supposed to use the most up-to-date version, but I'm getting the impression that /std:c++latest might not be a full release or something.

  • yobro

    i got a whole mess off errors

  • micuaderno

    i got this error by testing compiler

    Severity    Code    Description    Project    File    Line    Suppression State
    Error    LNK1168    cannot open

  • orb

    i get an error unrecognised command line option -wsign-conversion-werror did u mean wisgn-conversion

  • TimT

    There needs to be something about setting the solution platform in Visual Basic. I'm using the latest version, and the example code here wouldn't compile until I set the platform to 'X64' on the compiler toolbar and in project properties.

  • don

    could i use sometimg like c++20

  • TheRote

    I get an error with "arr" in line 23 it says "undeclared identifier"

  • fox

    i pasted the code into visual 2019 in c++17 but its not working
    what can i do?

    edit im such a doofus ive gone to general instead of languages
    my bad sorry

Leave a Comment

Put all code inside code tags: [code]your code here[/code]