int main() { int a = 0; #ifdef DBUG a = 5; #endif printf("===%d\n",a); return 0; } 对应Makefile文件 all:a.out debug:b.out mv b.out a.out a.out:compile_macro_test.c gcc<−o<−o@ b.out:compile_macro_test.c gcc-DDBUG<−o<−o@ .PHOHY:clean clean: rm *....
本文链接地址:【整理】gcc -D 选项 编译时添加宏定义 在一段C/C++代码中,如果我们想动态控制宏定义,可以通过GCC的编译选项进行控制。 如下代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 #include <stdio.h> #include <stdlib.h> intmain(intargc,char* argv[]) ...