本文共 423 字,大约阅读时间需要 1 分钟。
1 2 3 4 5 6 7 8 | #FILENAME:Makefile export SAI=y ifeq ($(SAI),y) CFLAGS += -DSAI endif all: @gcc $(CFLAGS) macro_test.c -o macro_test |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /*FILENAME:macro_test.c*/ #include <stdio.h> #include <stdlib.h> int main( int argc, char * argv[]) { #ifdef SAI printf ( "I am in SAI env\n" ); #endif printf ( "hi everyone\n" ); return 0; } |
在Makefile中 把
export SAI=y or SAI=n
就可以決定有沒有定義SAI在C code中
转载地址:http://kqsgi.baihongyu.com/