Referencing C functions in static library from C++

别说谁变了你拦得住时间么 提交于 2019-12-05 14:49:34

The other solution (to the one suggested originally by Yann) is to surround your "C" header with:

 #ifdef __cplusplus
 extern "C" {
 #endif

 #ifdef __cplusplus
 }
 #endif 

Which saves you from having to remember to do:

 extern "C" {
 #include "foo.h"
 }

every place you use foo.h

Make sure to use:

extern "C" {
 #include "myHeader.h"
}

Or else the C++ compiler will generate symbol names which are name-mangled.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!