外部工程:
a.cpp定义函数:
extern "C" int GetScreen()
{
...
return 0;
}
a.h定义
...
int GetScreen();
...
先用“插入工程到工作区”将那工程加进现有工作区中,然后设置了“从属性”从属现有工程。
现有工程中Dlg.cpp:
#include "../bn/a.h"
...
{
nRet=GetScreen();
}报错:
Dlg.obj : error LNK2001: unresolved external symbol _GetScreen
a.cpp定义函数:
extern "C" int GetScreen()
{
...
return 0;
}
a.h定义
...
int GetScreen();
...
先用“插入工程到工作区”将那工程加进现有工作区中,然后设置了“从属性”从属现有工程。
现有工程中Dlg.cpp:
#include "../bn/a.h"
...
{
nRet=GetScreen();
}报错:
Dlg.obj : error LNK2001: unresolved external symbol _GetScreen
extern "C"{
#endif
int GetScreen();
#ifdef __cplusplus
};
#endif找个系统头文件,应该可以看到
#ifdef __cplusplus
extern "C" {
#endif
extern int sizex;
int GetScreen();
.......
#ifdef __cplusplus
} // End of extern "C"
#endif这个外部工程能编译,是生成lib的
还有a.h里面的变量sizex这种用都没报错,就函数出错
别人的程序也是这么用的没问题,不知道是我工程设置少了什么东西么