Seeing expanded C macros

后端 未结 12 1060
清歌不尽
清歌不尽 2020-11-28 05:31

If I want to expand a C macro, what are some good ways to do that (besides tracing it manually)?

For instance, GTK_WIDGET_SET_FLAGS, it uses a macro that

12条回答
  •  粉色の甜心
    2020-11-28 05:57

    When trapped in a sketchy IDE, try something like

    #define DISPLAY_VALUE2(x) #x
    #define DISPLAY_VALUE(x) DISPLAY_VALUE2(x)
    #pragma message("#DEFINE F_CPU " DISPLAY_VALUE(F_CPU))
    

    to produce

    …/sketch_may21a.ino: In function 'void loop()':
    …/sketch_may21a.ino:10:54: note: #pragma message: #DEFINE F_CPU 16000000L
    #pragma message("#DEFINE F_CPU " DISPLAY_VALUE(F_CPU))
                                                         ^
    

    thanks to "mdematos" at http://MicroChip.com/forums/m724722.aspx

提交回复
热议问题