Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1514244
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: C/C++

2012-12-21 09:58:25

1.

点击(此处)折叠或打开

  1. #ifndef _DEBUG_H_
  2. #define _DEBUG_H_

  3. #include <stdio.h>

  4. #define DEBUG 0
  5. #define TRACE 0

  6. #if DEBUG
  7. #define PDEBUG(fmt, args...) fprintf(stderr, fmt, ##args)
  8. #else
  9. #define PDEBUG(fmt, args...)
  10. #endif

  11. #if TRACE
  12. #define PTRACE(fmt, args...) fprintf(stdout, fmt, ##args)
  13. #else
  14. #define PTRACE(fmt, args...)
  15. #endif


  16. #endif
2.

点击(此处)折叠或打开

  1. #ifndef __DEBUG_H__
  2. #define __DEBUG_H__

  3. #undef DEBUG
  4. #define DEBUG

  5. #ifdef DEBUG
  6. #include <stdio.h>
  7. #include <stdarg.h>

  8. #define DebugWhere() \
  9.     printf("FILE:%s,FUNCTION:%s,LINE:%d\n",\
  10.             __FILE__,__FUNCTION__,__LINE__)

  11. static void debug_p(const char *format ,...)
  12. {
  13.     va_list args;

  14.     va_start(args ,format);
  15.     vprintf(format,args);
  16.     va_end(args);
  17. }

  18. #else
  19. #define DebugWhere() \
  20.     printf("FILE:%s,FUNCTION:%s,LINE:%d\n",\
  21.             __FILE__,__FUNCTION__,__LINE__)

  22. static void debug_p(const char *format ,...)
  23. {
  24. }

  25. #endif

  26. #endif


阅读(2215) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~