-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sharadh Rajaraman
committed
Jul 16, 2024
1 parent
865a8e5
commit 8f9c90b
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// REQUIRES: system-windows | ||
|
||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: split-file %s %t | ||
|
||
// RUN: %clang_cl /std:c++20 --precompile "%/t/Hello.cppm" "/Fo%/t/Hello.pcm" | ||
// RUN: %clang_cl /std:c++20 %/t/use.cpp -fmodule-file=Hello=%/t/Hello.pcm %/t/Hello.pcm /Fo%/t/SimpleHelloWorld.exe 2>&1 | ||
|
||
// RUN: %/t/SimpleHelloWorld.exe | ||
// CHECK: Simple Hello World! | ||
|
||
//--- Hello.cppm | ||
module; | ||
#include <iostream> | ||
export module Hello; | ||
export void hello() { | ||
std::cout << "Simple Hello World!\n"; | ||
} | ||
|
||
//--- use.cpp | ||
import Hello; | ||
int main() { | ||
hello(); | ||
return 0; | ||
} | ||
|
||
//--- M.cppm | ||
export module M; | ||
export import :interface_part; | ||
import :impl_part; | ||
export void Hello(); | ||
|
||
//--- interface_part.cpp | ||
export module M:interface_part; | ||
export void World(); | ||
|
||
//--- impl_part.cppm | ||
module; | ||
#include <iostream> | ||
#include <string> | ||
module M:impl_part; | ||
import :interface_part; | ||
|
||
std::string W = "World!"; | ||
void World() { | ||
std::cout << W << std::endl; | ||
} | ||
|
||
//--- Impl.cpp | ||
module; | ||
#include <iostream> | ||
module M; | ||
void Hello() { | ||
std::cout << "Complex Hello "; | ||
} | ||
|
||
//--- User.cpp | ||
import M; | ||
int main() { | ||
Hello(); | ||
World(); | ||
return 0; | ||
} | ||
|