Llvm g ++ preprocessor passes

Suppose I want to write my own preprocessor.

So I want something like this:

all * .cpp and * .hpp (even included), before going to g ++, they go:

file --> my preprocessor -> g++

Is there an easy way to do this within LLVM? that is, add a step that says: "after downloading the source file, pass it through this program before compiling it"?

Thank!

+3
source share
2 answers

Ideas:

  • Hack cpp. You can easily ( -no-integrated-cpp) do gccto invoke your version cpp, which will call real cpp.
  • gcc -E, , , "#include".
  • prepreprocessor, . *.cppanon → *.cpp → *.o; *.hppanon → *.hpp;
  • #define.
  • FUSE, gcc.

: 4,3,1,2,5.

+1

, Clang , , , .

0

Source: https://habr.com/ru/post/1732995/


All Articles