问题的展示如题: 在C代码中定义了 函数,在C++中需要引用这个函数,但是实用直接包含时报错 undefined reference 。
在 头文件中 函数前 加上如下代码即可
#ifdef __cplusplus
extern "C"
#endif
如果是要外扩多个程序如下
#ifdef __cplusplus
extern "C"
{
#endif
char* Load_File_RAW(const char* filename);
void Fprint_String(const char *buffer,const char* Outname,const char* Mode);
#ifdef __cplusplus
}
#endif