preload
十一月 13

假如在C++ 中要呼叫C 的function,
則需加入如下宣告:


extern "C" {
   void c_function_name(void);
}

而比較好的作法是在c 的header file 中作如下的宣告:


#ifndef     __xxxx_H
#define     __xxxx_H
#ifdef __cplusplus
extern  "C" {
#endif    

/* put your c function definiction here */

void c_function_00(void);
void c_function_01(void);
void c_function_02(void);

#ifdef __cplusplus
}
#endif    

#endif      // __xxxx_H

Comments are closed.