Created
April 29, 2021 08:07
-
-
Save heapwolf/5a33659fd65c0bbe7bc43baa2c362b86 to your computer and use it in GitHub Desktop.
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
# | |
# clean up any existing artifacts | |
# | |
rm -rf build/dist | |
mkdir -p build/dist >/dev/null 2>&1 | |
# | |
# compile a module | |
# | |
clang++ -std=c++2a \ | |
-c hello.cxx \ | |
-fmodules \ | |
-Xclang -emit-module-interface \ | |
-o build/hello.pcm | |
# | |
# compile the code that uses it | |
# | |
clang++ -std=c++2a \ | |
-fmodules \ | |
-fprebuilt-module-path=build \ | |
main.cxx \ | |
hello.cxx \ | |
-o build/dist/hello \ | |
-fmodule-file=helloworld=build/hello.pcm | |
# | |
# run it | |
# | |
./build/dist/hello |
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
export module helloworld; | |
export namespace helloworld { | |
auto hello () { | |
return "Hello, world"; | |
} | |
} |
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
import <iostream>; | |
import helloworld; | |
int main() { | |
std::cout << helloworld::hello() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment