Search code examples
c++c++17atom-editorcompiler-flags

How do I upgrade to C++17?


I am using Atom as my IDE, my current __cplusplus = 201402 which is C++14 and my compiler is g++ (GCC) 9.2.0.

How do I upgrade to C++17 or C++20?

Everything I've searched up involves using another IDE (Microsoft Visual Studio).


Solution

  • You don't "upgrade" to newer C++ standards.
    You can upgrade compiler to newer version supporting latest standards.

    As of today, most compilers are set to C++14 by default.
    To change it you need to pass additional argument during compilation.

    For example, to compile hello.cpp with GCC for C++17 you need to execute

    g++ -std=c++17 hello.cpp
    

    You need to check how to pass compiler flags (or set standards) in your IDE / editor / build system.


    I'm not familiar with Atom, but I've found this:

    In the settings, click on Packages, then search for gpp-compiler. You should see a settings button – click on it and edit the command line options to suit your needs.