C++ 叮当声和C++;模块TS
我很难让模块ts在clang上工作(都随Xcode 9.3 beta版和最新的7.0.0 trunk提供)。我在这里和其他平台上找到了其他答案,但我仍然无法找到答案。以下是我到目前为止的情况: main.cpp 根据各种建议,我做了以下工作:C++ 叮当声和C++;模块TS,c++,module,clang,C++,Module,Clang,我很难让模块ts在clang上工作(都随Xcode 9.3 beta版和最新的7.0.0 trunk提供)。我在这里和其他平台上找到了其他答案,但我仍然无法找到答案。以下是我到目前为止的情况: main.cpp 根据各种建议,我做了以下工作: clang -fmodules-ts -std=c++17 --precompile -o stuff.pcm module.cppm clang -fmodules-ts -std=c++17 -fmodule-file=stuff.pcm main.
clang -fmodules-ts -std=c++17 --precompile -o stuff.pcm module.cppm
clang -fmodules-ts -std=c++17 -fmodule-file=stuff.pcm main.cpp
这将导致链接器错误(whatever()未找到)。我不知道如何继续进行
注意:我尝试了-fpmodule path=。
而不是-fmodule file
,然后它抱怨未知模块
如果有人能告诉我如何在Xcode中设置它,那就更好了
免责声明:我对使用模块映射和传统包含的解决方案不感兴趣。我对模块的兴趣不是关于提高编译时间,而是关于正确地模块化我的代码(特别是模板代码)。现在我所有的代码都在头文件中,大多数函数都声明为静态的 事实证明,还需要编译预编译模块文件,方法是将其编译为对象文件,然后链接该文件,或者通过快捷方式:
clang++ -fmodules-ts -std=c++17 -o main -fmodule-file=module.pcm main.cpp module.pcm
我想这是有道理的(如果你认为模块是AST转储,因此只是另一种源文件)。我还发现,如果模块名和模块文件名相同,可以使用-fpmodule path=。
选项,而不是指定-fmodule file
尽管如此,仍然有很多事情让我困惑。例如,诸如始终\u inline
或noinline
之类的属性似乎不受尊重。当优化打开时,编译器将内联函数
clang -fmodules-ts -std=c++17 --precompile -o stuff.pcm module.cppm
clang -fmodules-ts -std=c++17 -fmodule-file=stuff.pcm main.cpp
clang++ -fmodules-ts -std=c++17 -o main -fmodule-file=module.pcm main.cpp module.pcm