-
-
Save Necklaces/7077a3ef6490960768c67d6b5437efa0 to your computer and use it in GitHub Desktop.
C++20 Hello World Module
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
https://github.com/steve-downey/module-hw/blob/master/main.cpp |
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
// hello.cpp | |
module; | |
#include <iostream> | |
#include <string_view> | |
export module smd.hello; | |
export namespace hello { | |
void hello(std::string_view name) | |
{ | |
std::cout << "Hello, " << name << "! \n"; | |
} | |
} // namespace 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
// main.cxx | |
import smd.hello; | |
int main() | |
{ | |
hello::hello("Steve"); | |
} |
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
main : main.o hello.o | |
g++-11 -o main main.o hello.o | |
main.o : main.cpp gcm.cache/smd.hello.gcm | |
g++-11 -fPIC -fmodules-ts -std=c++20 -o main.o -c main.cpp | |
hello.o: hello.cpp | |
g++-11 -fPIC -fmodules-ts -std=c++20 -o hello.o -c hello.cpp | |
gcm.cache/smd.hello.gcm: hello.o | |
@test -f $@ || rm -f $< | |
@test -f $@ || $(MAKE) $< | |
clean: | |
rm hello.o main.o gcm.cache/smd.hello.gcm | |
clean-gcm: | |
rm gcm.cache/smd.hello.gcm | |
test: | |
./main | |
all: main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment