Is this a good way to embed debugging message in my program? (Macros)

前端 未结 3 941
说谎
说谎 2021-01-22 08:52

in the Debug.h file, I have the following:

#ifdef DEBUG_FLAG
    #define DEBUG(msg) std::cerr << #msg << std::endl
#else
    #define DEBUG(msg) for(;         


        
3条回答
  •  礼貌的吻别
    2021-01-22 09:30

    You also need the while (0) for your debug macro. Will be very painful to debug if/else cases without it (if you are lucky, you will get a compiler error). See this question for more details.

提交回复
热议问题