Issue 57289
Summary [C++20] [Modules] Enable to compile demo examples in one go
Labels c++20, clang:driver, clang:modules
Assignees
Reporter ChuanqiXu9
    See https://discourse.llvm.org/t/make-command-line-support-for-c-20-module-uniform-with-gcc/59144 for a completed example.

Simply, for a hello world example:

```C++
// say_hello.cpp
module;
#include <iostream>
#include <string_view>
export module Hello;
export void SayHello(std::string_view const &name)
{
  std::cout << "Hello " << name << "!\n";
}
// main.cpp
#include <string_view>
import Hello;
int main() {
  SayHello("world");
  return 0;
}
```

The GCC could compile it in one go:

```
g++ -std=c++20 -fmodules-ts say_hello.cpp main.cpp
```

But clang need to compile it in two steps at least:

```
clang++ -std=c++20  --precompile say_hello.cpp -o Hello.pcm
clang++ -std=c++20  -fprebuilt-module-path=. main.cpp Hello.pcm
```

So in this demo example, the command line interface of GCC is slightly more friendly than Clang.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to