首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++ 包孕非系统的C头文件,不知道这样写为什么错了?

2013-03-12 
C++ 包含非系统的C头文件,不知道这样写为什么错了??本帖最后由 akconandpeter 于 2013-03-07 15:12:43 编

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

两个下划线

热点排行