Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1239335
  • 博文数量: 264
  • 博客积分: 10772
  • 博客等级: 上将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 11:54
文章分类

全部博文(264)

文章存档

2012年(4)

2011年(51)

2010年(31)

2009年(57)

2008年(51)

2007年(70)

分类: C/C++

2008-12-22 15:12:41

-D name, Predefine name as a macro, with definition 1.(给所编译文件定义一个宏其值为1)

# vi test.c
---------------------------------
#include

#define ADD(x, y)        (x) + (y) + 10
#undef ADD
#define ADD(x, y)        (x) + (y)

#undef PDEBUG            /* undef it, just in case */
#ifdef
DEBUG
#define PDEBUG(fmt, args...)    printf("cmmb_inno: line %d - %s():"fmt, __LINE__, __FUNCTION__, ##args)
#else
#define PDEBUG(fmt, args...)
#endif

int main()
{
    PDEBUG("%s and %s\n", "zengxl", "luol");
    printf("10 + 8 = %d\n", ADD(10, 8));
}


--------------------------------
# gcc test.c -D DEBUG
# ./a.out
cmmb_inno: line 16 - main():zengxl and luol
10 + 8 = 18
# gcc test.c
# ./a.out
10 + 8 = 18
阅读(9028) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

HughNian2016-04-15 16:35:37

文明上网,理性发言