#ifdef _cplusplus extern “C“ 含义及应用
应用 含义 extern
2023-09-14 09:05:45 时间
#ifdef _cplusplus:编译器如果是C++
extern"C" 来告诉编译器:这是一个用C写成的库文件,请用C的方式来链接它们。
他们经常出现在.h文件中。
例:
#ifndef _INC_MYSOCKETCLIENT_H_
#define _INC_MYSOCKETCLIENT_H_
//#define Import_SSS
#ifdef Import_SSS
#define API _declspec(dllexport)
#else
#define API _declspec(dllimport)
#endif
#ifdef _cplusplus//extern"C" 来告诉编译器:这是一个用C写成的库文件,请用C的方式来链接它们。
extern "C" {
#endif // _cplusplus
API//导出函数,让外界调用。
int socketClient_Init(void **handle);
API
int socketClient_Send(void *handle, unsigned char *buf, int buflen);
API
int socketClient_Recv(void *handle, unsigned char *buf, int *buflen);
API
int socketClient_Destory(void *handle);
#ifdef _cplusplus
}
#endif // _cplusplus
#endif //_INC_MYSOCKETCLIENT_H_
相关文章
- 【零开始搭建SpringCloud Alibaba】搭建nacos应用端
- 【Visual Studio 2019】创建 MFC 桌面程序 ( 安装 MFC 开发组件 | 创建 MFC 应用 | MFC 应用窗口编辑 | 为按钮添加点击事件 | 修改按钮文字 | 打开应用 )
- SAP Fiori 应用 url 中的 DraftUUID 参数的含义
- Linux串口多路复用技术应用研究(linux串口多路复用)
- Flatpak 为 Linux 带来了独立应用
- Linux及ed2k协议技术的应用(linuxed2k)
- Qt 5.6在Linux上的应用(qt5.6linux)
- MySQL实现的天花板函数CEIL的应用(ceil mysql)
- BI工具Oracle应用提升经济效益(bi工具oracle方面)
- SSM框架下Redis的实现应用(ssm中redis的使用)
- 微软翻译应用新增地区口音功能
- javascript控制swfObject应用介绍