Created
March 8, 2022 16:47
-
-
Save andijcr/ee1d0962692f1aca94b64cbd7bdd0066 to your computer and use it in GitHub Desktop.
gcc 11 module example
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; // module declaration | |
import <iostream>; // import declaration | |
export void hello() { // export declaration | |
std::cout << "Hello world!\n"; | |
} | |
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 helloworld; // import declaration | |
int main() { | |
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
all: hello | |
gcm.cache: | |
g++ -std=c++20 -fmodules-ts -xc++-system-header iostream | |
helloworld.o: helloworld.cxx gcm.cache | |
g++ -std=c++20 -fmodules-ts -c helloworld.cxx -o helloworld.o | |
hello: helloworld.o | |
g++ -std=c++20 -fmodules-ts main.cpp helloworld.o -o hello | |
clean: | |
rm -fr gcm.cache | |
rm -f helloworld.o hello | |
.PHONY: all clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment