Which C++ standard is the default when compiling with g++?

后端 未结 9 595
故里飘歌
故里飘歌 2020-11-29 23:59

I have a piece of code that looks like the following. Let\'s say it\'s in a file named example.cpp

#include 
#include 

        
9条回答
  •  日久生厌
    2020-11-30 00:02

    The default language standards for both C and C++ are specified in the GCC Manuals. You can find these as follows:

    Browse to https://gcc.gnu.org/onlinedocs/

    Select the GCC #.## Manual link for the version of GCC you are interested in, e.g. for GCC 7.5.0:

    https://gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc/

    Click the topic link Language Standards Supported by GCC, followed by the topic C++ Language (or C language). Either of these topics will have a sentence such as:

    The default, if no C++ language dialect options are given, is -std=gnu++14.

    The default, if no C language dialect options are given, is -std=gnu11.

    The above two examples are for GCC 7.5.0.

提交回复
热议问题