Run preprocessor only but with only for certain statements

前端 未结 5 1117
-上瘾入骨i
-上瘾入骨i 2020-12-29 07:49

I have a number of debug statements defined in a program, and I want to be able to make a copy of the source without these statements.

In order to do this I first lo

5条回答
  •  清歌不尽
    2020-12-29 08:35

    There's no direct way to do that with the gcc preprocessor, though if you only include system headers, you might have some luck with gcc -E -nostdinc.

    However, you can comment out the #include directives, and other preprocessor directives you don't want processed, and run the code through the preprocessor (gcc -E or cpp) , that way only the macro you want expanded(the ones not commented out) gets expanded.

提交回复
热议问题