Run a “light” preprocessor for GCC

前端 未结 5 802
误落风尘
误落风尘 2021-02-07 10:37

Is there a way to run the GCC preprocessor, but only for user-defined macros?

I have a few one-liners and some #ifdef, etc. conditionals, and I want to see

5条回答
  •  醉话见心
    2021-02-07 11:27

    gcc  -E inputfile.c > outputfile.c
    

    outputfile.c will have your preprocessed code, but all macros will be expanded.

    I find this trick very useful when debugging compilation of large systems with tons of includes, compiler flags, and makefile variables. It will expose include files that don't have header guards, and a bunch of other problems too.

提交回复
热议问题