您的位置:首页 > 其它

GCC的DEBUG和release版本编译方法

2011-12-05 19:15 260 查看
利用gcc的 -DDEBUG选项。

1. 源文件DEBUG.c中有:

#include <stdio.h>

int main(int argc, char *argv[])

{

#ifdef DEBUG

printf("DEBUG is definded \n");

#else

printf("DEBUG is not definded \n");

#endif

}

2. Makefile文件为:

DEBUG=

CFLAG= -g

debug: DEBUG.c

gcc $(DEBUG) $(CFLAG) -o $@ $^

3. 输入:gcc -g -o debug DEBUG.c

./debug

out: DEBUG is not definded

4. 输入:gcc -DDEBUG -g -o debug DEBUG.c

./debug

out: DEBUG is definded

这样 DEBUG版本和 release版本都有了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: