C++ 包含非系统的C头文件,不知道这样写为什么错了??
本帖最后由 akconandpeter 于 2013-03-07 15:12:43 编辑 //pro1.h
#ifdef _cplusplus
extern "C"
{
#endif
void PrintMessage();
#ifdef _cplusplus
};
#endif
//pro1.c
#include <stdio.h>
#include "pro1.h"
void PrintMessage()
{
printf("%s","hello world !");
}
//main.cpp
#include "pro1.h"
int main()
{
PrintMessage();
return 0;
}
main.obj : error LNK2001: unresolved external symbol "void __cdecl PrintMessage(void)" (?PrintMessage@@YAXXZ)
Debug/pro1.exe : fatal error LNK1120: 1 unresolved externals
求原因,求解释??
c++
[解决办法]
#ifdef __cplusplus
extern "C"
{
#endif
void PrintMessage();
#ifdef __cplusplus
};
#endif
两个下划线