环境:
- Ubuntu 16.04 64 位
- g++ 版本 5.4.0
这是代码:
#include <numeric>
...
auto g = std::gcd(10, 4);
...
我在编译命令中打开了-std=c++17
选项:
g++ -m64 -std=c++17 -c -g -w -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
然后我得到了错误:
error: 'gcd' is not a member of 'std'
来自this webpage , std::gcd
是从 C++17 开始引入的。
来自this webpage ,我的g++版本支持C++17。
但是为什么还是有错误呢?相同的代码在 Visual Studio 2017 中编译时不会出现任何错误。
最佳答案
关于c++ - std::gcd 无法在 g++ 5.4.0 中编译 - 'gcd' 不是 'std' 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54746702/