c语言开发套路-怎样快速调用别人的一套接口 api模型的抽象

版权声明:欢迎转载请注明转自方辰昱的博客https://blog.csdn.net/viafcccy https://blog.csdn.net/viafcccy/article/details/84594058

圈出的部分要用直接copy stdio.h中的这个部分

这段代码的意思就是 如果是cpp编译器 请使用c语言的规范去编译下面的代码

假设现在有这样一个头文件

#pragma once

//SOCKET_H
#ifndef _SOCKETCLIENT_H
#endif _SOCKETCLIENT_H

#ifdef  __cplusplus
extern "C" {
#endif
	//第一套api函数

	//socket客户端环境初始化
	int socketclient_init(void **handle);

	//socket客户端报文发送
	int socketclient_send(void *handle, unsigned char *buf, int buflen);

	//socket客户端报文接受
	int socketclient_recv(void *handle, unsigned char *buf, int *buflen);

	//socket客户端环境释放
	int socketclient_destory(void *handle);

	//第二套api函数
	//socket客户端环境初始化
	int socketclient_init2(void **handle);

	//socket客户端报文发送
	int socketclient_send2(void *handle, unsigned char *buf, int buflen);

	//socket客户端报文接受
	int socketclient_recv2(void *handle, unsigned char **buf, int *buflen);

	//socket客户端环境释放
	int socketclient_destory2(void **handle)

#ifdef _cplusplus
}
#endif

我们只需要打桩

就是复制我们要使用的函数  return 0 然后调用起来

#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <string.h>


//socket客户端环境初始化
int socketclient_init(void **handle);
{
return 0;
}

//socket客户端报文发送
int socketclient_send(void *handle, unsigned char *buf, int buflen);
{
return 0;
}

//socket客户端报文接受
int socketclient_recv(void *handle, unsigned char *buf, int *buflen);
{
return 0;
}

//socket客户端环境释放
int socketclient_destory(void *handle);
{
return 0;
}

void main()
{
	printf("hello...\n");
	system("pause");
	return;
}

猜你喜欢

转载自blog.csdn.net/viafcccy/article/details/84594058