Linking C++ modules TS using clang

筅森魡賤 提交于 2019-12-01 14:34:31

Like what https://blogs.msdn.microsoft.com/vcblog/2015/12/03/c-modules-in-vs-2015-update-1/ says, .cppm (.ixx) translates to .pcm (.ifc) and .o (.obj).

But unlike cl.exe, which automatically produce these two files, Clang's .o file must be compiled from its .pcm file:

clang++ --std=c++17 -fmodules-ts -c foo.pcm -o foo.o

With foo.cppm and bar.cpp above, the commands would be like:

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

In the producing module (foo.cppm) you need to omit the keyword export from the module definition.

// foo.cppm
module foo;

export void test() {
}

Everything else should work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!