c debug代码

#define DEBUG 1
#define debug(format, ...) do{if(DEBUG)fprintf (stdout, format, ## __VA_ARGS__);}while(0)

通用版:

#define DEBUG
#include <stdarg.h>
int debug(const char *fmt, ...)
{
#ifdef DEBUG
char printf_buf[1024];
va_list args;
int printed;
va_start(args, fmt);
printed = vsprintf(printf_buf, fmt, args);
va_end(args);
puts(printf_buf);
return printed;
#endif
return 0;
}

//debug函数完全是printf函数源码

原文地址:https://www.cnblogs.com/yangyh/p/1779339.html