What's the point of including -std=c++0x in a G++ compile command?

后端 未结 3 1164
失恋的感觉
失恋的感觉 2021-01-15 02:16

I have recently started learning C++ and, since I\'m on Linux, I\'m compiling using G++.

Now, the tutorial I\'m following says

If you happen t

3条回答
  •  醉话见心
    2021-01-15 03:13

    By default, GCC compiles C++-code for gnu++98, which is a fancy way of saying the C++98 standard plus lots of gnu extenstions.

    You use -std=??? to say to the compiler what standard it should follow.
    Don't omit -pedantic though, or it will squint on standards-conformance.

    The options you could choose:

    standard          with gnu extensions
    
    c++98             gnu++98
    c++03             gnu++03
    c++11 (c++0x)     gnu++11 (gnu++0x)
    c++14 (c++1y)     gnu++14 (gnu++1y)
    

    Coming up:

    c++1z             gnu++1z (Planned for release sometime in 2017, might even make it.)
    

    GCC manual: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Standards.html#Standards

    Also, ask for full warnings, so add -Wall -Wextra.

    There are preprocessor-defines for making the library include additional checks:

    • _GLIBCXX_CONCEPT_CHECKS to add additional compile-time-checks for some templates prerequisites. Beware that those checks don't actually always do what they should, and are thus deprecated.
    • _GLIBCXX_DEBUG. Enable the libraries debug-mode. This has considerable runtime-overhead.
    • _GLIBCXX_DEBUG_PEDANTIC Same as above, but checks against the standards requirements instead of only against the implementations.

提交回复
热议问题