c++ - g++ 标准支持

标签 c++ gcc g++ standards

读到这里我有点困惑:Gcc 4.5 online manual --- Standards section .

他们解释了这一点

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). These standards are referred to as C++98 and C++03, respectively. GCC implements the majority of C++98 (export is a notable exception) and most of the changes in C++03.

但是他们没有说明 gcc 是否支持“裸”98 C++ 或仅支持更正后的 C++03。在“C 语言”部分解释得更清楚:

Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, 2004 and 2007. GCC does not support the uncorrected version.

所以我的问题是:g++ 是否也是这种情况(不支持未修正的标准)?

选择 g++ 标准的唯一 4 个选项是 -std=c++98-std=gnu++98-std= c++0x-std=gnu++0x。对吗?

最后一个子问题:-ansi 选项是什么?它只用于C模式吗?

编辑:

-ansi A synonym for -std=c89 (for C) or -std=c++98

最佳答案

gcc 不支持未修正的标准,它的目标是(虽然没有达到 100%)C++03 一致性。从技术上讲,目前只有一个 C++ 标准,包括 TC1 在内的版本就是它。正如它所说“支持 C++03 中的大部分更改。要选择此标准...使用选项之一 -ansi-std=c++98”。

不支持或选择已过时且未更正的 1998 版标准。

关于c++ - g++ 标准支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3595750/

相关文章:

c++ - 使用G++编译C++程序时出错

c++ - 对齐特定 pragma packed struct 成员的内存地址?

gcc - gcc 链接器映射文件的用途是什么?

c++ - Arduino双命令

c++ - 传递和更新结构数组

c++ - shared_ptr 对象的析构函数从未被调用

c++ - std::promise <void>是无锁的吗?

linux - 为什么 32 位 .deb 包不能安装在 64 位 Ubuntu 上?

c++ - 如何仅在某些时候生成编译器警告?

c++ - 似乎无法在碰撞、散列时打破 while 循环