C++如何调用C开发的DLL

来源:互联网 发布:阿尔法软件使用视频 编辑:程序博客网 时间:2024/05/01 03:21

在一个C++工程中调用C开发的动态库,包含动态库中的头文件时,需要在调用的头文件中添加如下语句:

#ifdef __cplusplus  
extern "C" {  
#endif 


#ifdef __cplusplus  
}  
#endif

实例如下:

#ifdef __cplusplus  
extern "C" {  
#endif 


#ifndef _TESTDATA_H
#define _TESTDATA_H
#include "SocketRecv.h"//the head file of  SocketRecv.dll


class CTestData
{
public:
CTestData();
~CTestData();
public:
WriteData(int nVal);
ReadData(int nVal);
};
#endif //_TESTDATA_H


#ifdef __cplusplus  
}  
#endif


0 0
原创粉丝点击