C????ε???C++??????
???????????? ???????[ 2012/8/21 13:31:59 ] ????????
??????????????????C????ε???C++???????????????????????????extern "C"???????????????ν??????????????????????????????????????£????????????C++????????????????????????Mark????
?????? C++ ?????????``extern "C"''??????? C++ ?????????????????????????????????? C ???? C++ ???????????????磺
// C++ code:
extern "C" void f(int);
void f(int i)
{
// ...
}
??????????????????? f()??
/* C code: */
void f(int);
void cc(int i)
{
f(i);
/* ... */
}
??????????????????????????????????????? C ????ó?????????????麯????????????????????????wrapper???????磺
// C++ code:
class C
{
// ...
virtual double f(int);
};
extern "C" double call_C_f(C* p?? int i) // wrapper function
{
return p->f(i);
}
???????????????????? C::f()??
/* C code: */
double call_C_f(struct C* p?? int i);
void ccc(struct C* p?? int i)
{
double d = call_C_f(p??i);
/* ... */
}
????????????? C ?????????????????????????????????????????? C ??????á????磺
// C++ code:
void f(int);
void f(double);
extern "C" void f_i(int i) { f(i); }
extern "C" void f_d(double d) { f(d); }
??????????????????????????? f()??
/* C code: */
void f_i(int);
void f_d(double);
void cccc(int i??double d)
{
f_i(i);
f_d(d);
/* ... */
}
?????????Щ????????????? C ????? C++ ????????????????????? C++ ??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11