读到这里我有点困惑: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/