C++内でCの関数を使用する
C++の関数からCの関数を呼び出す
上位から下位を呼び出す際には何も問題はなさそうだが
C++の関数からCの関数を呼び出すためにひと手間はかかる。
ヘッダーファイル sample_c.h
C++内でCプログラム側で定義された
関数あるいは変数であることを示す
extern "C" {
変数およびプロトタイプ宣言etc
}
■sample_c.hの内容
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef __SAMPLE_C__
#define __SAMPLE_C__
#ifdef __cplusplus
extern "C" {
#endif
extern int sample_funcC(char *param);
#ifdef __cplusplus
}
#endif
#endif