您的位置:首页 > 编程语言 > C语言/C++

C++ Language Standards Supported by GCC ( GCC 支持的C++语言标准 )

2017-04-26 17:31 417 查看

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++98C++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'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ GCC 语言标准