#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函数源码

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2021-08-04
  • 2021-09-10
  • 2021-10-19
  • 2022-12-23
猜你喜欢
  • 2021-09-20
  • 2022-01-01
  • 2021-12-24
  • 2021-08-06
  • 2021-09-13
  • 2022-02-01
相关资源
相似解决方案