Created
May 17, 2019 00:28
-
-
Save aisamanra/abfd42f12245fb418998df32b6ae2860 to your computer and use it in GitHub Desktop.
C++ 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
import speech; | |
#include <iostream> | |
int main() { | |
std::cout << get_phrase() << std::endl; | |
} |
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
CPPFLAGS = -std=c++1z -fmodules-ts | |
ALL: main | |
main: speech.o main.cc | |
clang++ $(CPPFLAGS) -fprebuilt-module-path=. -o $@ $^ | |
speech.o: speech.pcm | |
clang++ $(CPPFLAGS) -o $@ -c $< | |
speech.pcm: speech.cppm | |
clang++ $(CPPFLAGS) --precompile -o $@ $< | |
clean: | |
rm -rf *.pcm *.o main |
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 speech; | |
export const char* get_phrase() { | |
return "Hello, world!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment