c++ - build2: 编译器不支持模块

标签 c++ clang++ c++-modules

我可以使用 build2 构建没有 c++ 模块的 c++ 项目,但是当我尝试配置 build2 并将其与 C++ 模块一起使用时,出现“编译器不支持模块”错误。

我确信我的编译器能够构建模块,因为我可以使用这些命令手动构建:

clang++ --std=c++17 -fmodules-ts --precompile foo.cppm -o foo.pcm
clang++ --std=c++17 -fmodules-ts --precompile foo2.cppm -o foo2.pcm
clang++ --std=c++17 -fmodules-ts -c foo.pcm -o foo.o
clang++ --std=c++17 -fmodules-ts -c foo2.pcm -o foo2.o
clang++ --std=c++17 -fmodules-ts -fprebuilt-module-path=. foo.o foo2.o bar.cpp

我的 clang 版本是 7.0.0:

$ clang++ --version
clang version 7.0.0- (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

为了在 build2 中启用模块支持,我在根 buildfile 中添加了以下行:

cxx.std = experimental

using cxx

assert $cxx.features.modules 'compiler does not support modules'

mxx{*}: extension = mxx
cxx{*}: extension = cxx

有什么问题吗?这是我第一次使用 build2,所以我可能会遗漏一些非常简单的东西。

最佳答案

管理它的工作。

据我所知,问题是我更改了 buildfile,但应该改用 build/root.build

关于c++ - build2: 编译器不支持模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51585674/

相关文章:

c++ - 模板特化 - clang 和 gcc 的不同结果

c++ - 如何在 C++20 中参数化模块?

c++ - dlopen/etc 不编译。未解析的符号

c++ - 多维 Mat 上的 opencv 滤波器

c++ - Clang 输出错误 "no matching construct for initialization"

c++ - cmake 如何在 Visual Studio 中激活 "Inherit from parent"链接选项

c++ - 如何在 CMake 中使用 VC++ 模块

c++ - 如何在 gcc 或 clang 中使用 c++20(启用模块)包含多个预编译头

c++ - 将派生类推送到c++中基类的 vector

c++ - 可以在 Lua 中加载 C++ dll 文件吗?