Skip to content
Advertisement

Can I squeeze my own 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 would probably not agree with me :).

Advertisement

Answer

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++”:

JavaScript

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

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement