c++ c 混合編程的 undefined reference問題

使用C++編程時,有時要用到第三方的庫,而第一方庫是以C給出的,奇怪的是明明已經把C文件加入工程,頭文件也已經引入,編譯裏仍是出現編程

undefined reference編譯

問題在這裏,第三方的C庫的頭文件沒有加入extern "C",在C文件的頭文件加入以下便可di

#ifdef  __cplusplus   文件

extern "C" {   undefined

#endif  

/* C頭文件的其它聲明 */

 

#ifdef  __cplusplus  

}  

#endif  /* end of __cplusplus */

相關文章
相關標籤/搜索