我正在尝试使用g ++ 9.3.0使用文档中提到的标志来编译C ++ 20代码,但我遇到了错误
#include <iostream>
#include <span>
void span_test() {
constexpr int a[] = {0, 1, 2, 3, 4};
auto s = std::span{a};
std::cout << s.size() << std::endl;
}
int main() {
span_test();
return 0;
}
我知道这不是与 C++20 兼容的最新版本的 g++。我需要使用 g++ 9.3.0 创建共享对象文件,因为我受到 Xcelium 的限制。
g++ -c -std=c++2a -fPIC libdpi.cpp -o libdpi.o
libdpi.cpp:2:10: fatal error: span: No such file or directory
2 | #include <span>
| ^~~~~~
compilation terminated.
g++ 9.3.0不支持span,g++ 10以上支持span。