作者coolmark (NNN )
看板EE_DSnP
標題[問題] undefined reference
時間Sun Jun 1 13:10:40 2008
請問一下我在試著要用aiger.c裡的function時
自己先在那裏寫了一個testprint() (回傳一個數字而已)
接著我在cirInterface.cpp裡寫了如下的
extern "C"
int testprint();
struct aiger;
int
aigToCir (const char *fileName){
int res = 0;
cout<<"YAYA"<<testprint();
return res;
}
compile會過,而且執行cirr hh.aig的確會print出testprint回傳的數字
但是!!!當我把int testprint();和struct aiger;這兩行上下對掉時
compile便出現undefined reference to 'testprint()' 出錯在cout<<"YAYA"...那一行
請問會甚麼會這樣呢?
加了一個struct aiger;怎會影響到testprint() ???謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.234
1F:推 timrau:因為缺少大括號,extern "C"的效力僅限於int testprint(); 06/01 13:13
2F:→ timrau:如果你兩行對調的話 int testprint()就沒有extern "C"加持 06/01 13:13
3F:→ timrau:它就會嘗試用C++的方式link testprint() 導致找不到 06/01 13:14
4F:→ coolmark:yayaya~~~thx a lot ! 06/01 13:34