How to know (in GCC) when given macro/preprocessor symbol gets declared?

后端 未结 6 548
無奈伤痛
無奈伤痛 2020-12-10 05:17

Suppose I have #define foo in various header files. It may expand to some different things. I would like to know (when compiling a .cc file) when a #define is encountered, t

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 05:56

    for the "to what it will expand" I use the -E switch in gcc which gives the preprocessed output. But there is no backtrace which macro came where from (or if there was a macro at all).

    Another option you might use is -g3, this adds debug information regarding the macros, i.e. you can later see in your debugger the definition of each macro.

提交回复
热议问题