请问:vc环境下,c文件中如何调用cpp文件里的函数啊?
rt。谢谢 问题点数:20、回复次数:7Top
1 楼pkrobbie(pkrobbie)回复于 2006-03-03 16:22:30 得分 10
// Declare the two functions ShowChar and GetChar
// with C linkage.
extern "C"
{
char ShowChar( char ch );
char GetChar( void );
}
// Define the two functions ShowChar and GetChar
// with C linkage.
extern "C" char ShowChar( char ch )
{
putchar( ch );
return ch;
}
extern "C" char GetChar( void )
{
char ch;
ch = getchar();
return ch;
}
Top
2 楼wzjall(风)回复于 2006-03-03 22:07:42 得分 0
支持楼上Top
3 楼yiyo2025(HenryKong)回复于 2006-03-03 22:56:50 得分 0
这是cpp调c吧,楼主好像问的是c调cpp,学习。
Top
4 楼vcps(灿)回复于 2006-03-04 11:51:43 得分 0
能不能说的明白点,在哪个文件里怎么写?
我的问题可以描述如下:
test1.cpp中定义了函数void fun1();
在test2.c中要用到fun1();
编译时没问题,在链解时显示在test2.obj中没有定义符号_fun1.
请问怎么解决啊?Top
5 楼shaoboailinglijun(邵波爱凌丽君)回复于 2006-03-04 12:22:11 得分 10
在C++primer第七章的7.7链接提示符:extern "C"介绍了Top
6 楼shaoboailinglijun(邵波爱凌丽君)回复于 2006-03-04 12:23:04 得分 0
还介绍怎么调用其他程序语言的函数Top
7 楼shaoboailinglijun(邵波爱凌丽君)回复于 2006-03-04 12:26:36 得分 0
在C++primer第七章的7.7链接提示符:extern "C"介绍了
C++调用C里的函数 C调用C++里的函数都有介绍 还介绍C++调用其他程序语言的函数
Top




