gpt4 book ai didi

c++ - 如何使用 Godbolt(编译器资源管理器)测试 C++ 模块?

转载 作者:行者123 更新时间:2023-12-03 06:49:40 29 4
gpt4 key购买 nike

为了询问或演示 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 编译

主.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 编译

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

最佳答案

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

关于c++ - 如何使用 Godbolt(编译器资源管理器)测试 C++ 模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60760248/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com