文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>gcc c99 可变参数宏 easy to debug

gcc c99 可变参数宏 easy to debug

时间:2009-05-07  来源:ubuntuer

gcc的预处理提供的可变参数宏定义真是好用:
#ifdef DEBUG

#define dbgprint(format,args...) \

fprintf(stderr, format, ##args)

#else

#define dbgprint(format,args...)

#endif

如此定义之后,代码中就可以用dbgprint了,例如dbgprint("aaa %s", __FILE__);。感觉这个功能比较Cool !

下面是C99的方法, :

#define dgbmsg(fmt,...) \

printf(fmt,__VA_ARGS__)

常用的:
#define dprintf(fmt, args...) printf("%s %s %d: "fmt"\n",__FILE__, __func__, __LINE__, ##args );

#define dputs(str) printf("%s %s %d: %s\n",__FILE__, __func__, __LINE__, str );
相关阅读 更多 +
排行榜 更多 +
味子夫

味子夫

购物比价 下载
恩猫

恩猫

购物比价 下载
街头纷争

街头纷争

动作格斗 下载