0

If --std= is not defined, what C++ standard does g++ 10.1.1 implement?

I couldn't find this in the manual. [Sure it must be somewhere.]

user2864740
  • 60,010
  • 15
  • 145
  • 220
andro
  • 901
  • 9
  • 20
  • https://stackoverflow.com/q/44734397/2864740 - There are several different options to gather the information per answers (man page, gdb output, release notes). I suppose it'd be nice _if_ there was `--show-defaults` or some such.. – user2864740 May 12 '20 at 00:51
  • 1
    And.. this is why I ensure (or, CMake ensures) that a specific standards version is specified in the projects I work on. – user2864740 May 12 '20 at 00:55
  • Certainty makes programming a lot more boring, but far, far more profitable. – user4581301 May 12 '20 at 01:17
  • It's in the manual. According to the documentation for gcc 10.1, if no C++ dialect is specified (`-std= ...`) the default is `-std=gnu++14`. That is stated at the end of section 2.2, in https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc.pdf . The dialect `gnu++14` is essentially C++14, with a few gnu-specific extensions. Dialects supported by different versions of gcc tend to only change with major releases, so I'd expect version 10.1.1 and 10.1.0 to be the same in this regard. – Peter May 12 '20 at 01:31
  • try outputting the value of `__cplusplus` – M.M May 12 '20 at 01:38
  • You could have tried `g++ -v helloworld.cpp` – Basile Starynkevitch May 12 '20 at 02:03
  • @BasileStarynkevitch `g++ -v` gives information about configuration and build settings for how the compiler was built. It includes the g++ version number (like 10.1 in this case) but does not include information about what dialect of the language the compiler supports. – Peter May 12 '20 at 02:22
  • Try my command. With an argument `g++ -v` shows the detailed run of `cc1plus` – Basile Starynkevitch May 12 '20 at 05:49

1 Answers1

1

According to the 10.1 manual (section 2.2 C++ Language, last line):

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

Admittedly, the URL suggests that this is information for 10.1.0 instead of 10.1.1. It seems unlikely that the default would change for that minor version step, but just in case, here's another reference: C++14 support in GCC with some emphasis added.

This mode is the default in GCC 6.1 and above; it can be explicitly selected with the -std=c++14 command-line flag, or -std=gnu++14 to enable GNU extensions as well.

JaMiT
  • 14,422
  • 4
  • 15
  • 31