Windows和Linux系统的Debug调试信息输出方法

#ifndef WIN32
#define DBG_OUT(args...) \
do{ \
	char buf[1024],line[512],file[512]; \
	char *p=file,*q; \
	sprintf(buf,args); \
	sprintf(line,"%s,%d",__FUNCTION__,__LINE__); \
	sprintf(file,"%s",__FILE__); \
	q = file+strlen(file); \
	while(('/' != *q) && (p != q)) q--; \
	while(*q) *p++ = *q++; *p='\0'; \
	fprintf(stderr,"[%s,%s],%s",file,line,buf); \
}while(0)
#else
#define DBG_OUT(x,...) \
do{ \
	char buf[1024],line[512],file[512]; \
	char *p=file,*q; \
	sprintf(buf,x,__VA_ARGS__); \
	sprintf(line,"%s,%d",__FUNCTION__,__LINE__); \
	sprintf(file,"%s",__FILE__); \
	q = file+strlen(file); \
	while(('\\' != *q) && (p != q)) q--; \
	q++; \
	while(*q) *p++ = *q++; *p='\0'; \
	fprintf(stderr,"[%s,%s] %s",file,line,buf); \
}while(0)
#endif

发布了71 篇原创文章 · 获赞 23 · 访问量 28万+

猜你喜欢

转载自blog.csdn.net/ssmile/article/details/8824293
今日推荐