Print information in “test mode” but not in “normal execution”

后端 未结 3 1675
没有蜡笔的小新
没有蜡笔的小新 2020-12-16 05:50

I am using an application in c++ that uses a special dprintf function to print information, this is an example:

dprintf(verbose, \"The value is: %d\", i);
         


        
3条回答
  •  有刺的猬
    2020-12-16 06:41

    #ifdef DEBUG
    #define dprintf(format, ...) real_dprintf(format, __VA_ARGS__)
    #else
    #define dprintf
    #endif
    

    Here real_dprintf() is the "real" function that is invoked, and dprintf() is just a macro wrapping the call.

提交回复
热议问题