【发布时间】:2016-12-25 09:34:40
【问题描述】:
我正在学习 gcc 选项 DDEBUG。
下面是我的简单测试代码:
#include <stdio.h>
#include <stdlib.h>
#ifdef DEBUG
#define debug(msg) printf("Debug: %s\n", msg)
#else
#define debug(msg)
#endif
int main(int argc, char const *argv[])
{
debug("Debug flag was defined\n");
printf("hello world\n");
return 0;
}
然后,我用gcc -DDEBUG=0 debug.c 编译,我希望“Debug flag was defined”不会被打印出来,但确实如此。我可以知道为什么-DDEBUG=0 不起作用吗?
【问题讨论】:
-
也许你把
#ifdef和#if混淆了
标签: c debugging gcc c-preprocessor