How can I get the default mode for a C ++ g ++ compiler without a link to a document?

I want to know the default mode for the c++current compiler g++. Besides linking to a document, for example this :

The default mode for C++ is now -std=gnu++14 instead of -std=gnu++98.

Is it possible to get this mode from the command line g++? I am trying to find this information with g++ -v:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 6.2.1 20160830 (GCC)

But, unfortunately, this does not provide this knowledge.

+4
source share
2 answers

You can always use man, for example: ((default note next to gnu++14)

man g++

...
       -std=
           Determine the language standard.   This option is currently only supported when compiling C or C++.

           The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98.  When a base standard is specified, the compiler accepts all programs following that standard plus those using GNU
           extensions that do not contradict it.  For example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO C90, such as
           omitting the middle term of a "?:" expression. On the other hand, when a GNU dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base standard.  As a result, some
           strict-conforming programs may be rejected.  The particular standard is used by -Wpedantic to identify which features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while
           -std=gnu99 -Wpedantic does not.

           A value for this option must be provided; possible values are

...

           c++14
           c++1y
               The 2014 ISO C++ standard plus amendments.  The name c++1y is deprecated.

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

If you want to get it on the command line (without a pager), you can specify a pager for manusing -P:

$ man -P cat g++ | grep "^[[:space:]]*\-std=[^s]" -A100 | grep -B2 "default.*C++"
           gnu++14
           gnu++1y
               GNU dialect of -std=c++14.  This is the default for C++ code.  The name gnu++1y is deprecated.
+2

, / .

, , , , , -std , ?:)

+2

Source: https://habr.com/ru/post/1665592/


All Articles