【发布时间】:2016-12-29 11:20:55
【问题描述】:
As it looks like Clang 正在为模块 TS 提供支持。我tried this out 使用 Clang,从 SVN(主干)编译,它按预期工作。
我想把它带到下一步,将catch 库包装到一个模块中。
我尝试以这种方式声明module.modulemap:
module Catch {
header "catch/catch.hpp"
export *
}
和main.cpp 包含:
import Catch;
int main(int argc, char* const argv[])
{
int result = Catch::Session().run(argc, argv);
return result;
}
compilation model 声明“模块的二进制表示由编译器根据需要自动生成。”
使用clang-4.0 -std=c++1z -fmodules-ts main.cpp 编译main.cpp 我得到:
main.cpp:1:8: fatal error: module 'Catch' not found
import Catch;
~~~~~~~^~~~~
1 error generated.
知道如何解决吗?
【问题讨论】:
-
尝试使用
-fmodule-file=<path>指定模块文件(clang 应该自动执行此操作,但我们正在调试)。 -
@ShmuelH。使用该选项 Clang 报告:致命错误:
file 'module.modulemap' is not a valid precompiled module file. -
我错了,是
-fmodule-map-file。 -
Clang 仍然在向
fatal error: module 'Catch' is needed but has not been provided, and implicit use of module files is disabled抱怨我试图玩一些标志,但它不起作用 -
@ShmuelH。我还需要提供
-fmodules-ts来启用模块,这与 clang 文档提供的-fmodules形成对比。 ://
标签: c++ module clang c++-modules