Reputation: 3581
In order to ask questions about or demonstrate bugs/features with self-written modules in C++20, it would be great to be able to use Matt Godbolt's compiler explorer.
Example:
test.cpp (module test):
export module test;
export template<typename T>
void do_something(const T&)
{
}
Compile with 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);
}
Compile with clang++ -std=c++20 -stdlib=libc++ -fmodules -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. main.cpp
Q: Is there a way to do this with compiler explorer?
Upvotes: 17
Views: 8222
Reputation: 51
Now we can!! https://godbolt.org/z/1szKxKMP6
With CMake 3.28 just merged in CE, it's even easier!
Upvotes: 5
Reputation: 146
Currently you cannot. A typical modules example needs multiple source files. Eg. in your case, main.cpp & test.cpp. This is not currently supported in GodBolt. I tried building using the raw github content on Godbolt. But it does not work. I have opened this request. Also see this ongoing request which seemingly is under process.
Upvotes: 6