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

后端 未结 9 599
故里飘歌
故里飘歌 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:29

    g++ man page actually tells what is the default standard for C++ code.

    Use following script to show the relevant part:

    man g++ | col -b | grep -B 1 -e '-std.* default'
    

    For example, in RHEL 6 g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23), the output:

             gnu++98
               GNU dialect of -std=c++98.  This is the default for C++ code.
    

    And in Fedora 28 g++ (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1), the output:

           gnu++1y
               GNU dialect of -std=c++14.  This is the default for C++ code.  The name gnu++1y is deprecated.
    

提交回复
热议问题