【发布时间】:2021-07-02 15:23:32
【问题描述】:
我正在尝试访问std::popcount,但似乎是only there in C++ 20。
当我尝试使用g++ -std=c++20 main.cpp 编译时,它显示g++: error: unrecognized command line option '-std=c++20'; did you mean '-std=c++03'
我如何告诉 g++ 使用 c++ 20?
我使用的是 Ubuntu 18.04
【问题讨论】:
-
您的
g++版本太旧。popcount(即-std=c++2a)至少需要 9+ 或 10+ 才能实际编写c++20。 -
您使用的是什么版本的 GCC?是include C++20 support吗?
-
重要提示:因为 ISO C++20 标准是最新的,所以 GCC 的支持是实验性的。 gcc.gnu.org/projects/cxx-status.html#cxx20