小编Nic*_*Nic的帖子

缺少 Apple Clang 13 C++20 模块支持

根据官方文档,Clang 13 通过使用-fmodules命令行参数支持 C++20 模块。

我什至无法在基于 Intel 或 M1 的 Mac 上使用 Clang 13 (macOS Monterey) 编译基本模块。

假设文件的文本内容如下module.cpp

export module a;

export int f(int a, int b) {
    return a + b;
}
Run Code Online (Sandbox Code Playgroud)

运行以下命令:

$ clang++ --version
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin21.1.0

$ clang++ -std=c++20 -stdlib=libc++ -fmodules -fbuiltin-module-map -c module.cpp 
module.cpp:1:8: error: expected template
export module a;
       ^
module.cpp:1:8: error: unknown type name 'module'
module.cpp:3:8: error: expected template
export int f(int a, …
Run Code Online (Sandbox Code Playgroud)

clang++ c++20 c++-modules apple-m1 macos-monterey

6
推荐指数
1
解决办法
8038
查看次数

标签 统计

apple-m1 ×1

c++-modules ×1

c++20 ×1

clang++ ×1

macos-monterey ×1