在GCC,Clang和MSVC有什么办法符合C ++ 98而不是C ++ 03? [英] In GCC, Clang and MSVC is there any way to conform against C++98 and not C++03?

查看:179
本文介绍了在GCC,Clang和MSVC有什么办法符合C ++ 98而不是C ++ 03?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

元问题建议 c ++ 98 c ++ 03 的问题同义词。问题asker跟着它是C ++ 98标准的值初始化部分吗?如果不是,为什么它添加在C ++ 03标准?,一个很好的问题,阐明了添加值初始化到C ++ 03。考虑这个问题是对后者的后续。

The meta question proposes that the c++98 and c++03 tags should be made synonyms. The question asker followed it up with Is value initialization part of the C++98 standard? If not, why was it added in the C++03 standard?, an excellent question which sheds light on the addition of value initialization to C++03. Consider this question to be a follow-up to the latter.

OP断言现代编译器不打扰C ++ 98和C ++ 03之间的区别。这是令人惊讶的,因为事实证明是三个现代编译器的情况。

The OP asserts that modern compilers do not bother distinguishing between C++98 and C++03. This was surprising to me, as it turns out to be the case for three modern compilers. Although this question could boil down to "RTFM", my searches have not found anything conclusive.

这个问题可以归结为RTFM他们的标准网页:

Their standards page:


原始ISO C ++标准以ISO标准发布
(ISO / IEC 14882:1998),并由技术勘误b(2003年)(ISO / IEC 14882:2003)。这些标准分别称为C ++ 98
和C ++ 03。 GCC实现了大多数C ++ 98(export
是一个值得注意的异常)和C ++ 03中的大部分更改。要在GCC中选择
此标准,请使用以下选项之一:-ansi,-std = c ++ 98或
-std = c ++ 03; ...

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. To select this standard in GCC, use one of the options -ansi, -std=c++98, or -std=c++03; ...

此外,他们的方言选项页面说明:

Furthermore, their dialect options page says:


在C ++模式下,[ansi]等效于-std = c ++ 98。

In C++ mode, [ansi] is equivalent to -std=c++98.

++ 98和c ++ 03在一起:

And group "c++98" and "c++03" together:



1998 ISO C ++标准加上2003技术勘误和一些
额外缺陷报告。与-ansi for C ++代码相同。

The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports. Same as -ansi for C++ code.


这似乎意味着没有办法打开 C ++ 98模式。

This seems to imply there is no way to turn on only C++98 mode.

发现Clang是他们的手册,它在 C ++语言功能

The only thing I found find for Clang was on their manual, it says under C++ Language Features:


clang完全实现所有标准C ++ 98,除了导出的
模板(在C ++ 11中删除),...

clang fully implements all of standard C++98 except for exported templates (which were removed in C++11), ...

没有提到C ++ 03。它还声明:

With no mention of C++03. It also states:


clang支持-std选项,这将更改语言模式clang
使用的语言。支持的C模式是c89,gnu89,c94,c99,gnu99,c11,
gnu11和这些模式的各种别名。如果没有指定-std选项是
,则clang默认为gnu11模式。许多C99和C11功能在早期模式中支持
作为合格扩展,并带有警告。

clang supports the -std option, which changes what language mode clang uses. The supported modes for C are c89, gnu89, c94, c99, gnu99, c11, gnu11, and various aliases for those modes. If no -std option is specified, clang defaults to gnu11 mode. Many C99 and C11 features are supported in earlier modes as a conforming extension, with a warning.

对于他们的C编译器,我不能找到任何关于C ++编译器的文档,例如哪些选项有效传递到 -std 。我只是假设Clang镜像GCC的方言选项(例如,C ++ 03在Clang上有效),虽然没有证据我不能这么结论。

This is of course for their C compiler, I was not able to find any documentation on the C++ compiler, such as which options are valid to pass to -std. I simply assume that Clang mirrors GCC's dialect options (for example, C++03 is valid on Clang), although without proof I cannot state so conclusively.

据我所知,MSVC不允许你像上面那样改变语言标准。在 MSDN 没有打开任何内容。看来他们实现C ++ 98 / C ++ 11,例如 Herb Sutter

As far as I know, MSVC doesn't allow you to change language standards like the two above do. A search for "C++98" on MSDN doesn't turn up anything. It appears that they implement C++98/C++11, for example as stated by Herb Sutter.

问题听起来很明显,元问题让我意识到不是那么明显。

Although these questions sound obvious, the meta question has made me realize that it is not so obvious.


  • 有没有办法使GCC只符合C ++ 98? 在gcc 中强制执行C ++ 98标准只需链接到相同的文档

  • Is there a way to make GCC only conform to C++98? Enforcing the C++98 standard in gcc simply links to the same documentation I did, without any further consideration on whether it really is conforming against C++98.

Clang是否符合C ++ 98,或者它们是否符合C ++ 98 C ++ 03?在哪里可以找到相关的文档?

Does Clang conform to C++98 or do they actually conform to C++03? Where can I find the relevant documentation for this?

有没有办法改变MSVC中的语言标准,使其只符合C ++ 98?

Same for MSVC. Is there a way to change language standards in MSVC to conform only against C++98?

推荐答案


有没有办法使GCC只符合C ++ 98?

Is there a way to make GCC only conform to C++98?

否。


Clang是否符合C ++ 98或者它们是否符合C ++ 03?在哪里可以找到相关文档?

Does Clang conform to C++98 or do they actually conform to C++03? Where can I find the relevant documentation for this?

Clang实现C ++ 03减 export

Clang implements C++03 minus export, just like GCC:


Clang实现了所有的ISO C ++ 1998标准(包括ISO C ++ 2003标准),除了导出(在C ++ 11中删除)。

Clang implements all of the ISO C++ 1998 standard (including the defects addressed in the ISO C++ 2003 standard) except for export (which was removed in C++11).




  • http://clang.llvm.org/cxx_status.html

    • http://clang.llvm.org/cxx_status.html

    • MSVC相同。有没有办法改变MSVC中的语言标准以仅符合C ++ 98?

      Same for MSVC. Is there a way to change language standards in MSVC to conform only against C++98?

      否。正如你所说,你不能在MSVC中指定C ++版本。有一个编译器标志列表,不是其中任何一个的函数。

      No. As you say, you cannot specify the C++ version in MSVC. There is a list of compiler flags and that is not the function of any of them.

      • http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx

      C ++ 03的整个要点是对C ++ 98进行更正,从而有效地直接替换它,而不是跟随它作为一个新的单位。想要还原那些修复没有意义。这就像要求Windows 7 SP2 启动到Windows 7 SP1模式。

      The whole point of C++03 was to make corrections to C++98 and thus to effectively replace it outright, rather than to follow it as a new unit. It does not make sense to want to "revert" those fixes. That would be like asking Windows 7 SP2 to boot into Windows 7 SP1 mode. It just isn't a model that anyone would want to support.

      虚构的

      这篇关于在GCC,Clang和MSVC有什么办法符合C ++ 98而不是C ++ 03?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆