1.name managling这里把它翻译为名字改编。
2.C++为了支持重载,需要进行name managling
3.extern “C”实现C与C++混合编程
#ifdef __cpluscplus
extern “C”
{
#endif
...//函数声明
#ifdef __cpluscplus
}
#endif
代码实例:
#include<iostream>
usingnamespace std;
void fun(inta, intb)
{
cout<<"int fun"<<endl;
}
void fun(doublea, doubleb)
{
cout<<"double fun"<<endl;
}
//extern "C"表示不进行名字改编,否则编译的时候重载函数编译器会对其名字进行改编
#ifdef__cpluscplus
extern"C"
{
#endif
void fun(inta)
{
cout<<"xxxx"<<endl;
}
void fun2(doublea)
{
cout<<"yyyy"<<endl;
}
#ifdef__cpluscplus
}
#endif
int main(void)
{
fun(3,4);
fun(3.3, 4.4);
fun(3);
return 0;
}