$ make clean
default settings: OP1 disable and use same_func1.c
rm *.o *~ test_same_func -f
$ make
cc -Wall -Werror -g3 -c test_same_func.c
cc -Wall -Werror -g3 -c same_func2.c
cc -o test_same_func test_same_func.o same_func2.o
$ gdb -ex 'file test_same_func' -ex 'info line func1' -ex 'quit'...
Line 11 of "same_func2.c" starts at address 0x400597 <func1> and ends at 0x40059b <func1+4>.
Hello World
same_func2.c: func1_NOT_OP1
設定巨集OP1,USE_FILE沒設定
gdb驗證結果的確是
編譯same_func2.c
使用OP1版本的func1()
12345678910111213
$ make clean
rm *.o *~ test_same_func -f
$ make EN_OP1=1
cc -Wall -Werror -g3 -DOP1=1 -c test_same_func.c
cc -Wall -Werror -g3 -DOP1=1 -c same_func2.c
cc -o test_same_func test_same_func.o same_func2.o
$ gdb -ex 'file test_same_func' -ex 'info line func1' -ex 'quit'...
Line 5 of "same_func2.c" starts at address 0x400597 <func1> and ends at 0x40059b <func1+4>.
Hello World
same_func2.c: func1_OP1
巨集OP1沒設定,但是設定USE_FILE
gdb驗證結果的確是
編譯same_func1.c
使用非OP1版本的func1()
12345678910111213
$ make clean
rm *.o *~ test_same_func -f
$ make USE_FILE=1
cc -Wall -Werror -g3 -c test_same_func.c
cc -Wall -Werror -g3 -c same_func1.c
cc -o test_same_func test_same_func.o same_func1.o
$ gdb -ex 'file test_same_func' -ex 'info line func1' -ex 'quit'...
Line 11 of "same_func1.c" starts at address 0x400597 <func1> and ends at 0x40059b <func1+4>.
Hello World
same_func1.c: func1_NOT_OP1
全部設定巨集OP1和USE_FILE
gdb驗證結果的確是
編譯same_func1.c
使用OP1版本的func1()
12345678910111213
$ make clean
rm *.o *~ test_same_func -f
$ make EN_OP1=1USE_FILE=1
cc -Wall -Werror -g3 -DOP1=1 -c test_same_func.c
cc -Wall -Werror -g3 -DOP1=1 -c same_func1.c
cc -o test_same_func test_same_func.o same_func1.o
$ gdb -ex 'file test_same_func' -ex 'info line func1' -ex 'quit'...
Line 5 of "same_func1.c" starts at address 0x400597 <func1> and ends at 0x40059b <func1+4>.
Hello World
same_func1.c: func1_OP1