-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
阅读(9178) | 评论(1) | 转发(1) |