当前位置: 代码迷 >> 综合 >> debug 打印 开关 设计(for c || C++)
  详细解决方案

debug 打印 开关 设计(for c || C++)

热度:65   发布时间:2024-01-16 14:42:57.0
一、
头文件:
#define debug 1
 
#if debug
#define dbg_print(format,args...)\
    do\
    {\
        printf("[%s][%d]"format,__FUNCTION__, __LINE__,## args);\
    }while(0)
#else
#define dbg_print(format,args...)
#endif
 
c文件中使用:
 
dbg_print("para is NULL");
 
dbg_print("value(%d) is err", value);
 
二、
》》头文件《《
 
/* 调试打印 */
#define DEBUG 0
#if DEBUG
#define DebugPrintval(x) \
printf("[%s]%s:%d:%s=%d\n", __FILE__, __FUNCTION__, __LINE__, #x, x)
 
#define DebugPrintStr(x) \
printf("
  相关解决方案