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 really upgrade* to newer C++ standards.
    You can upgrade the 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:

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

    You ought to check how to pass compiler flags (or set options) 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.


    * Although, when somebody says about upgrading to newer standard, they might mean refactor an existing codebase to work under the newer revision, e.g. by replacing deprecated functionalities, fixing subtle differences, updating used syntax etc.