Chinaunix首页 | 论坛 | 博客
  • 博客访问: 139719
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 876
  • 用 户 组: 普通用户
  • 注册时间: 2013-04-09 10:56
文章分类

全部博文(20)

文章存档

2013年(20)

我的朋友

分类: LINUX

2013-04-11 16:08:53

 下面这段代码来自LDD3

/*

 * Macros to help debugging

 */

#undef PDEBUG             /* undef it, just in case */

#ifdef SCULL_DEBUG

#  ifdef __KERNEL__

     /* This one if debugging is on, and kernel space */

#    define PDEBUG(fmt, args...) printk( KERN_DEBUG "scull: " fmt, ## args)

#  else

     /* This one for user space */

#    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)

#  endif

#else

#  define PDEBUG(fmt, args...) /* not debugging: nothing */

#endif

解释:不管是否定义了PDEBUG,取消对PDEBUG定义,以防重复。

如果定义了SCULL_DEBUG,则开启调试功能,否则PDEBUG什么事情不做。

如果定义了__KERNEL__,表明处于内核空间,需要调用printk进行调试信息打印,否则在用户控件,调用fprintf将调试信息打印到stderr中。

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