Using the GNU Compiler Collection
Language Standards Supported by GCC
2.2 C++ Language
GCC supports the original ISO C++ standard published in 1998, and the 2011 and 2014 revisions.
GCC支持1998年出版的原始 ISO C ++標準,以及2011年和2014年版本。
The original ISO C++ standard was published as the ISO standard (ISO/IEC 14882:1998)
and amended by a Technical Corrigenda published in 2003 (ISO/IEC 14882:2003).
原始 ISO C++ 標準作爲ISO標準 (ISO/IEC 14882:1998) 發佈並經2003年出版的技術勘誤表 (ISO/IEC 14882:2003) 修訂。
These standards are referred to as C++98 and C++03, respectively.
這些標準分別被稱爲 C++98 和 C++03。
GCC implements the majority of C++98 (export is a notable exception) and most of the changes in C++03.
GCC實現了大部分 C++98(比如導出就是一明顯的例外),和 C++03 中的大部分更改。
To select this standard in GCC, use one of the options ‘-ansi’, ‘-std=c++98’, or ‘-std=c++03’;
要在GCC中選擇此標準,請使用
'-ansi'
,'-std=c++98'
或'-std=c++03'
選項中的一個;
to obtain all the diagnostics required by the standard, you should also specify ‘-pedantic’ (or
‘-pedantic-errors’ if you want them to be errors rather than warnings).
要獲得該標準所需的所有診斷信息,還應指定
'-pedantic'
(或'-pedantic-errors'
如果你希望他們是錯誤,而不是警告)
A revised ISO C++ standard was published in 2011 as ISO/IEC 14882:2011, and is referred to as C++11;
2011年修訂後的ISO C++標準於以ISO/IEC 14882:2011出版,被稱爲 C++11;
before its publication it was commonly referred to as C++0x. C++11 contains several changes to the C++ language, all of which have been implemented in GCC.
For details see https://gcc.gnu.org/projects/cxx0x.html.
在發佈之前通常被稱爲C++0x。C++11包含對C ++語言的幾個更改都已在GCC中實現。
更多細節詳見 https://gcc.gnu.org/projects/cxx0x.html.
To select this standard in GCC, use the option‘-std=c++11’.
要在GCC中選擇此標準,請使用選項
'-std=c++11'
。
Another revised ISO C++ standard was published in 2014 as ISO/IEC 14882:2014, and is referred to as C++14;
另一個修訂的ISO C++標準於2014年以 ISO/IEC 14882:2014 出版,被稱爲 C++14;
before its publication it was sometimes referred to as C++1y.
在發佈之前有時被稱爲 C++1y。
C++14 contains several further changes to the C++ language, all of which have been implemented in GCC.
For details see https://gcc.gnu.org/projects/cxx1y.html.
C++14 包含對C++語言幾個特性的修改,所有這些都已在GCC中實現。
更多細節詳見 https://gcc.gnu.org/projects/cxx1y.html.
To select this standard in GCC, use the option ‘-std=c++14’.
要在GCC中選擇此標準,請使用選項
'-std=c++14'
。
GCC also supports the C++ Concepts Technical Specifcation, ISO/IEC TS 19217:2015,
which allows constraints to be defined for templates, allowing template arguments to be
checked and for templates to be overloaded or specialized based on the constraints.
GCC還支持 C++ 概念技術 ISO/IEC TS 19217:2015 規範,
這允許爲模板定義約束, 允許使用模板參數檢查和模板被重載或基於特定的約束。
Support for C++ Concepts is included in an experimental C++1z mode that corresponds to the next
revision of the ISO C++ standard, expected to be published in 2017.
GCC還支持在實驗C++1z模式中的C++概念,對應於下一個版本的 ISO C++標準,預計將於2017年發佈。
To enable C++1z support in GCC, use the option ‘-std=c++17’ or ‘-std=c++1z’.
要在GCC中啓用對C++1z模式的支持,請使用選項
'-std=c++17'
或'-std=c ++ 1z'
。
More information about the C++ standards is available on the ISO C++ committee’s web site at http://www.open-std.org/jtc1/sc22/wg21/.
有關C ++標準的更多信息可以在ISO C++委員會網站中找到 http://www.open-std.org/jtc1/sc22/wg21/
To obtain all the diagnostics required by any of the standard versions described above you should specify ‘-pedantic’ or ‘-pedantic-errors’, otherwise GCC will allow some non-ISO C++ features as extensions.
See Section 3.8 [Warning Options], page 59.
獲得上述任何標準版本所需的所有診斷信息你應該指定
'-pedantic'
或'-pedantic-errors'
否則GCC將允許一些非ISO C++標準的功能作爲擴展
詳見 3.8 節 [警告選項], 59頁
By default, GCC also provides some additional extensions to the C++ language that on rare occasions conflict with the C++ standard.
See Section 3.5 [C++ Dialect Options],page 40.
默認情況下,GCC還爲C ++語言提供了一些額外的擴展在極少的情況下與 C++標準相沖突。
詳見 3.5 節 [C++ 方言選項], 40 頁
Use of the ‘-std’ options listed above disables these extensions where they they conflict with the C++ standard version selected.
使用上面列出的
'-std'
選項可以禁用這些擴展特性,使GCC與所選擇的C++標準的版本一致。
You may also select an extended version of the C++ language explicitly with
‘-std=gnu++98’ (for C++98 with GNU extensions), or
‘-std=gnu++11’ (for C++11 with GNU extensions), or
‘-std=gnu++14’ (for C++14 with GNU extensions), or
‘-std=gnu++1z’ (for C++1z with GNU extensions).
您也可以使用下列選項明確地選擇C ++語言的擴展版本
'-std=gnu++98'
(for C++98 with GNU extensions)
'-std=gnu++11'
(for C++11 with GNU extensions), or
'-std=gnu++14'
(for C++14 with GNU extensions), or
'-std=gnu++1z'
(for C++1z with GNU extensions).
The default, if no C++ language dialect options are given, is ‘-std=gnu++14’.
默認情況下,如果沒有給出 C++ 語言方言選項,則爲
'-std=gnu++14'
。