gcc -D选项 编译时添加宏定义
2018-01-03 11:54
387 查看
//test.cpp
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
#ifndef
NO_DEBUG
printf("gcc -D\n");
#endif
return 0;
}
//Makefile
DEBUG=
CFLAGS=-g $(DEBUG)
all:a.out
g++ CFLAGS -o a.out
//make
make DEBUG='-D NO_DEBUG'
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
#ifndef
NO_DEBUG
printf("gcc -D\n");
#endif
return 0;
}
//Makefile
DEBUG=
CFLAGS=-g $(DEBUG)
all:a.out
g++ CFLAGS -o a.out
//make
make DEBUG='-D NO_DEBUG'