【问题标题】:GCC 8.3 can't compile std::bind_frontGCC 8.3 无法编译 std::bind_front
【发布时间】:2020-05-18 23:52:12
【问题描述】:

g++ 是否有可能以比我指定的旧标准编译我的程序?

我编译:

g++ -Wall -Wextra -pedantic -O3 -std=c++2a -fconcepts

并且编译器无法识别 bind_front 函数(我包括 <functional> )。编译器版本为 GCC 8.3。

【问题讨论】:

  • 请显示完整的错误输出(我怀疑你需要std::
  • 你的 GCC 版本是多少?带有 -std=c++2a 标志的 GCC 9.2 编译成功
  • 我也得了性病。
  • 请向我们展示您复制错误的代码的minimal reproducible example
  • 我现在没有电脑。所以我无法检查 g++ 版本。但是昨天我重新安装了 g++,我认为它大约是 8.3

标签: c++ compilation standards c++20 gcc8


【解决方案1】:

GCC 8.3 不支持std::bind_front。检查here

您需要使用 GCC 9.1 或 9.2。检查here

How to install GCC 9?

更新

正如@walnut 的评论所说,自 Ubuntu 19.04 以来标准存储库中有一个 g++ 9 包。

【讨论】:

  • 链接问题中的答案似乎有点过时了。自 Ubuntu 19.04 以来,标准存储库中似乎有一个 g++-9 包:packages.ubuntu.com/en/disco/g++-9
  • 我有 ubuntu 19.04,我已经更新并安装了 g++。当我输入g++ --version 时,它仍然是 8.3,这怎么可能? / 我想用 g++ 命令作为默认 g++9 编译)
  • @ziyiyituxe 您是否按照我提供的链接中的说明进行操作?
  • 是的,我使用了这个命令sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install gcc-9,我可以用 g++-9 编译,但我需要 g++ 默认为 -9
  • @ziyiyituxe 试试这个sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9
猜你喜欢
  • 2012-01-23
  • 1970-01-01
  • 2016-11-13
  • 1970-01-01
  • 2013-01-29
  • 1970-01-01
  • 1970-01-01
  • 2015-06-04
  • 2017-06-27
相关资源
最近更新 更多