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

后端 未结 6 540
無奈伤痛
無奈伤痛 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:44

    It wont help you find where it was defined but you can see the definition for a particular file by using the -E -dM flags

    g++ -E -dM file.cpp | grep MACRO
    

提交回复
热议问题