#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#define GlobalDebugFlag 1
#define DEBUG_PRINT_WITH_TIME(fmt, args...) { \
do \
{ \
if (GlobalDebugFlag == 1 ) \
{ \
time_t timep = {0}; \
struct tm *p = NULL; \
time(&timep); \
p=localtime(&timep); \
fprintf(stdout, "[%4d-%02d-%02d %02d:%02d:%02d %s %s %d] ", \
(1900+p->tm_year), \
(1+p->tm_mon), \
p->tm_mday, \
p->tm_hour, \
p->tm_min, \
p->tm_sec, \
__FILE__, \
__FUNCTION__, \
__LINE__); \
fprintf(stdout, fmt "\n", ##args); \
} \
} \
while(0); \
}
C语言添加DEBUG,可以显示时间、文件、函数、行对于调试时比较方便
最新推荐文章于 2024-04-21 12:08:44 发布