【发布时间】:2021-05-22 01:04:10
【问题描述】:
我的 g++ 版本是 Ubuntu 5.4.0:
g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12)
从手册页中,我看到:
c++14
c++1y
The 2014 ISO C++ standard plus amendments. The name c++1y is deprecated.
gnu++14
gnu++1y
GNU dialect of -std=c++14. The name gnu++1y is deprecated.
c++1z
The next revision of the ISO C++ standard, tentatively planned for 2017. Support
is highly experimental, and will almost certainly change in incompatible ways in
future releases.
这是否意味着 c++17 的“-std=c++1z”?我很困惑应该为 c++17 使用什么,因为有些程序只是直接使用“-std=c++17”并使用这个 g++ 成功编译。
【问题讨论】:
-
这不是你自己试一试就能回答的问题吗?编译器应该告诉你它是否是一个有效的选项,所以你可以试试
-std=c++17,看看你是否收到错误消息。 -
对,我的问题听起来很奇怪。我确实尝试了 -std=c++17 一些代码,但是在 c++17 中使用“内联静态”功能时失败了。但是其他一些使用 -std=c++17 和这个 g++ 的安装工作得很好。所以我很困惑
-
我认为您的 G++ 版本不够最新。见stackoverflow.com/a/48312534/62576 和gcc.gnu.org/projects/cxx-status.html
-
谢谢。第一个链接说这个 g++ 对 c++17 的支持有限,所以这可以解释为什么有些代码可以工作,而其他代码不能。你知道如何在 Ubuntu 16.04 中升级 g++ 吗?
-
嗯...在 gcc.gnu.org?
标签: g++