-std= 语言标准
2016/5/27 13:13:10
gcc 版本:
1 | cts@SuSe-CTS2:~> gcc --version |
-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 c89 or c++98, and GNU dialects(方言;同源语) of those standards, such as gnu89 or gnu++98. By specifing a base standard, the compiler will accept all programs following that standard and those using GNU extensions that do not contradict it. For example, -std=c89 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, by specifing a GNU dialect of a standard, all features the compiler support are enabled, even when those features change the meaning of the base standard and some strict-conforming programs may be rejected. The particular standard is used by -pedantic(迂腐的;学究式的) to identify which features are GNU extensions given that version of the standard. For example -std=gnu89 -pedantic would warn about C++ style // comments, while -std=gnu99 -pedantic would not.
A value for this option must be provided; possible values are
c89
iso9899:1990
Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code.iso9899:199409
ISO C90 as modified in amendment 1.c99
c9x
iso9899:1999
iso9899:199x
ISO C99. Note that this standard is not yet fully supported; see http://gcc.gnu.org/gcc-4.3/c99status.html for more information. The names c9x and iso9899:199x are deprecated.gnu89
GNU dialect of ISO C90 (including some C99 features). This is the default for C code.gnu99
gnu9x
GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, this will become the default. The name gnu9x is deprecated.c++98
The 1998 ISO C++ standard plus amendments. Same as -ansi for C++ code.gnu++98
GNU dialect of -std=c++98. This is the default for C++ code.c++0x
The working draft of the upcoming ISO C++0x standard. This option enables experimental features that are likely to be included in C++0x. The working draft is constantly changing, and any feature that is enabled by this flag may be removed from future versions of GCC if it is not part of the C++0x standard.gnu++0x
GNU dialect of -std=c++0x. This option enables experimental features that may be removed in future versions of GCC.
目前在 gcc 官方上最新版为 gcc 6.1 ,其中:
‘gnu11’
‘gnu1x’
GNU dialect of ISO C11. This is the default for C code. The name ‘gnu1x’ is deprecated.‘c++98’
‘c++03’
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports. Same as -ansi for C++ code.‘gnu++98’
‘gnu++03’
GNU dialect of -std=c++98.‘c++11’
‘c++0x’
The 2011 ISO C++ standard plus amendments. The name ‘c++0x’ is deprecated.‘gnu++11’
‘gnu++0x’
GNU dialect of -std=c++11. The name ‘gnu++0x’ is deprecated.‘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.