为什么“-std=c++0x”是仍然需要 g++ 4.6.2?
我下载并构建了 gcc 4.6.2。我发现对于 C++11 功能,仍然需要命令行选项 -std=c++0x
。这是为什么?不是应该默认支持吗?
$ g++ --version
g++ (GCC) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I downloaded and built gcc 4.6.2. I find that for C++11 features, the command line option -std=c++0x
is still needed. Why is that? Isn't is supposed to support it by default?
$ g++ --version
g++ (GCC) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
因为
Because
阅读 GCC 网站:
GCC 4.6 中实验性 C++0x 支持的状态
因此你不能将默认的东西设置为实验性的。
而且,它是在C++11标准发布之前,并且没有定义实际名称,这解释了为什么C++0x而不是C++11。
如果您对 GCC 4.7 感兴趣,它仍处于实验阶段:
实验 C+ 的状态+11 GCC 4.7 支持
Reading GCC website:
Status of Experimental C++0x Support in GCC 4.6
Thus you can't make default something experimental.
Moreover, It was before C++11 standard release, and the actual name was not defined, which explains why C++0x and not C++11.
If you're interested by GCC 4.7, it's still experimental:
Status of Experimental C++11 Support in GCC 4.7
它仍然是需要的,并且在可预见的未来可能会保持这种状态,因为 C ++11 与 C++03 不兼容。将 G++ 更改为默认编译 C++11 会破坏许多现有代码。
It is still needed, and will probably stay this way for the foreseeable future, because C++11 has incompatibilities with C++03. Changing G++ to compile C++11 by default will break a lot of existing code.
我认为它被称为
0x
的事实给了你一个提示。它甚至不完整(请参阅http://gcc.gnu.org/projects/cxx0x.html)I think the fact that it's called
0x
gives you a hint. It's not even complete (see http://gcc.gnu.org/projects/cxx0x.html)