作者moonjustin (快点放长假吧@@)
看板EE_DSnP
标题Re: [问题] prob 2(b)小题
时间Thu Oct 19 13:04:36 2006
※ 引述《ric2k1 (Ric)》之铭言:
: ※ 引述《moonjustin (快点放长假吧@@)》之铭言:
: : 题目题是说会有linking的问题
: : 但我显示出来的讯息是
: : Compiling: main.cpp
: : Compiling: undef1.cpp
: : g++ -c -o undef2.o undef2.C
: : Compiling: undef2.o
: : Achiving libundef2.a
: : Linking undef
: : 他似乎很顺利的完成了联结?
: : 可是我Makefile档案的部份都没改?
: Please note that in Prob 2 (a) ---
: "...Don't fix them by declaring local variables."
谢谢老师
我那时候是以为
宣告在undef1.cpp里面的f()函数里才算local variable
所以我就把它宣告在函数外面
这样写之後link会没问题应该是因为
我在indef1.cpp 里面已经宣告int a;
而且在Makefile里面 lib的连结原本就错误
所以它找不到另一个在lib里面的int a
所以才会连结成功
总之谢谢了^^"
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.18.220