为什么“-std=c++0x”是仍然需要 g++ 4.6.2?

发布于 2024-12-22 19:05:41 字数 369 浏览 3 评论 0原文

我下载并构建了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

带上头具痛哭 2024-12-29 19:05:41

因为

  • C++11 只有 4 个月的历史,对它的支持还远未完成或经过测试,
  • 在没有重大公告的情况下更改默认值,而且人们的准备阶段并不好。
  • 尚不清楚默认值是否会更改(请参阅 -std =C99)。

Because

  • C++11 is only 4 Months old and support for it is far from being complete or tested
  • changing the default without a big announcement and preparation phase for people is not nice
  • It is not clear if the default will ever change (see -std=C99).
标点 2024-12-29 19:05:41

阅读 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

凉月流沐 2024-12-29 19:05:41

它仍然是需要的,并且在可预见的未来可能会保持这种状态,因为 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.

仅此而已 2024-12-29 19:05:41

我认为它被称为 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文