开发者

Can I squeeze my own program between the preprocessor and compiler?

开发者 https://www.devze.com 2023-01-22 06:59 出处:网络
Is this a stupid question, or can I specify g++ to use a program between the preprocessor and compiler?

Is this a stupid question, or can I specify g++ to use a program between the preprocessor and compiler?

Alternatively, I know that I can just run the preprocessor on a file (hence all the files). Then I am guessing there is a switch to run only the compiler. So I can manually invoke these two and put my program between. If so, how do I run compiler (and linker?) only?

I'd rather prefer the first method as our builder woul开发者_StackOverflowd probably not agree with me :).


To run an alternative preprocessor, the man page suggests using -no-integrated-cpp and -B.

I have no experience with these, so I suggest you read the relevant parts in the man page.


Alternatively, you can run the compiler without invoking the preprocessor by telling g++ that the language is "preprocessed C++":

g++ -x c++-cpp-output

g++ will also recognize files with the suffix .ii as preprocessed C++, so the pipeline becomes:

source.cpp -> source.ii: g++ -o source.ii -E source.cpp
source.ii -> source.custom.ii: <custom step>
source.custom.ii -> source.o: g++ -o source.o -c source.custom.ii
source.o -> source: g++ -o source source.o


Look at the -Xpreprocessor option, this allows you to define new pre-processor interpretations

0

精彩评论

暂无评论...
验证码 换一张
取 消