【问题标题】:How to test C++ modules with godbolt (compiler explorer)?如何使用 Godbolt(编译器资源管理器)测试 C++ 模块?
【发布时间】:2020-06-30 18:27:53
【问题描述】:

为了就 C++20 中自写模块的问题/功能提出问题或演示,如果能够使用 Matt Godbolt's compiler explorer,那就太好了。

示例:

test.cpp(模块测试):

export module test;

export template<typename T>
void do_something(const T&)
{
}

使用clang++ -std=c++20 -stdlib=libc++ -fmodules -c -Xclang -emit-module-interface -o test.pcm test.cpp编译

main.cpp:

import test;

int main() {
    do_something(7);
}

clang++ -std=c++20 -stdlib=libc++ -fmodules -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. main.cpp编译

问:有没有办法通过编译器资源管理器做到这一点?

【问题讨论】:

    标签: c++ c++20 c++-modules compiler-explorer


    【解决方案1】:

    目前你不能。一个典型的模块示例需要多个源文件。例如。在您的情况下,main.cpp 和 test.cpp。 GodBolt 目前不支持此功能。 我尝试使用 Godbolt 上的原始 github 内容进行构建。但它不起作用。我已经打开了这个request。 另请参阅此正在进行的request,它似乎正在处理中。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-25
    • 2019-06-23
    • 2010-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多