查看 clang-5.0 release notes它说“C++ coroutines TS已着陆”,并建议查看this example开始。我显然可以在线运行该示例,因此我决定在我的 Ubuntu Server 16.04 Xenial 机器上尝试一下。
从全新安装中,我刚刚尝试过
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
sudo apt-get update
sudo apt-get install -y clang-5.0 libc++-dev
然后径直走向
clang++-5.0 -Wall -Wextra -std=gnu++2a "-fcoroutines-ts" "-stdlib=libc++" -o test.out test.cpp
(test.cpp
是 the aforementioned example 的复制粘贴)
但是,我只是得到
coroutines.cpp:2:10: fatal error: 'experimental/coroutine' file not found
#include <experimental/coroutine>
所以我可以想象我缺少一些东西,无论是安装还是在编译标志中。我尝试在网上查找,但找不到任何有用的信息。
我做错了什么?
最佳答案
您链接的存储库似乎仅提供工具链,但不提供 header 。
安装libc++-dev时,您从 Ubuntu 存储库安装了软件包,该存储库不包括实验目录中的头文件。
您可以查看this问题是自己构建 libc++ 并适本地设置工具链。
关于c++ - 在 Ubuntu 16.04 下运行协程示例给出 "' 实验/协程'文件未找到”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49881782/