Skip to content

Instantly share code, notes, and snippets.

@aisamanra
Created May 17, 2019 00:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aisamanra/abfd42f12245fb418998df32b6ae2860 to your computer and use it in GitHub Desktop.
Save aisamanra/abfd42f12245fb418998df32b6ae2860 to your computer and use it in GitHub Desktop.
C++ module example
import speech;
#include <iostream>
int main() {
std::cout << get_phrase() << std::endl;
}
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
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