c++ - 在 Ubuntu 16.04 下运行协程示例给出 "' 实验/协程'文件未找到”

标签 c++ clang++ coroutine

查看 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.cppthe 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/

相关文章:

android - -Werror,-Wundefined-inline 是什么意思?

android - 如何在单击按钮时使用运行阻止

c++ - 相同的代码和不同的结果

c++ - 摆脱 “Undeclared identifier”错误

c++ - ROS 移动约束

python - asyncio : loop. run_until_complete(loop.create_task(f)) 打印 "Task exception was never retrieved",即使它显然已传播

lua - 监督 Lua 中的协程

c++ - c/c++函数的源代码

c++ - 如何使父类的模板方法对子类可见?

c++ - 隐藏私有(private)重载虚函数?