请教一个关于C与C++兼容的问题~~~

来源:百度知道 编辑:UC知道 时间:2024/05/17 22:09:09
我现在想在一个C语言程序调用一个在win32下写的函数,请问我能不能调用~~~我知道一般都是后面的往前面的兼容。。。。。请知道的能不能实现我这个要求呢?
我的意思是:我现在的主程序是用C写的,但是我另外那个副函数是用win32写的。后缀是.cpp文件,我现在在主程序中直接调用.cpp中的函数,我就只把那个.h文件添加进去了。可是一连接就错误。说Linking...
AVIEDIT.OBJ : error LNK2001: unresolved external symbol _AviToBmp
Debug/Editing APIs in AVIfile.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
请问我怎么来解决这个问题啊?

该成这样
//test.c
#include"1.h"
void main()
{
test();
}

//1.h
#ifdef __cplusplus
extern "C"
#endif
void test();

//1.cpp

#include <iostream>
#include "1.h"

void test()
{
std::cout<<"test"<<std::endl;
}