为什么C ++ 11编译器支持仍需要一个标志? [英] Why C++11 compiler support still requires a flag?

查看:151
本文介绍了为什么C ++ 11编译器支持仍需要一个标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道编程语言的实验性功能不应该默认启用,所以我欢迎标志 -std = c ++ 0x -std = c ++ 1y 。然而,C ++ 11现在是标准的,因为几年。为什么编译器仍然需要 -std = c ++ 11 才能支持其功能?

I understand that experimental features of a programming language should not be enabled by default so I welcome the flags -std=c++0x and -std=c++1y. However C++11 is now standard since a couple of years. Why compilers still require -std=c++11 to enable the support for its features?

推荐答案

C ++ 11已经标准使用了几年,但是编译器不会将其默认模式切换到C ++ 11,直到:

C++11 has been standard for a couple of years, but a compiler isn't going to switch its default mode to C++11 until:


  • 绝对最低限度,C ++ 11支持在该编译器及其使用的库中完成。

  • 最好是,编译器中主要的版本号增加,因为C ++ 11不是完全向后兼容的

基本上,很多人(和makefile)依赖于编译器是一个符合的C ++ 03编译器,或者至少在它的不一致性是已知的。由于C ++ 11引入了与C ++ 03不兼容的新实例,所以更改是潜在的创伤。

Basically, lots of people (and makefiles) rely on the compiler being a conforming C++03 compiler, or at least on its non-conformance being known. Since C++11 introduces new instances of non-conformance with C++03, the change is potentially traumatic.

可以说,任何依赖C ++ 03的人都应该指定一个选项来说,并且改变默认模式对他们没有什么区别。但是一旦你记录了你的编译器的默认值,人们就会有意或无意地依赖它。

Arguably anyone relying on C++03 should have specified an option to say so, and changes to the default mode would make no difference to them. But once you've documented your compiler's default, people are going to rely that, either intentionally or otherwise.

特别是对于gcc,4.8.2手册页说支持C ++ 11仍然是实验性的。所以我认为最终你的问题的答案可能是,需要2年多的时间才能正确实施C ++ 11,甚至从所有的工作草案标准。

For gcc in particular, the 4.8.2 man page says that "support for C++11 is still experimental". So I think ultimately the answer to your question may be that it takes more than 2 years to properly implement C++11, even starting from all the work done with draft standards.

这篇关于为什么C ++ 11编译器支持仍需要一个标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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