当前位置:网站首页>一种API写法
一种API写法
2022-08-07 08:20:00 【lixingdian】
根据需要的功能写固定的函数结构体,如下:
struct app_callbacks
{
void (*app_on_connection)(const uint8_t, struct gapc_connection_req_ind const *);
void (*app_on_disconnect)(struct gapc_disconnect_ind const *);
}
再初始化时定义全局静态结构体,如下:
static const struct app_callbacks user_app_callbacks = {
.app_on_connection = user_app_connection,
.app_on_disconnect = user_app_disconnect,
};
使用时可以直接如下使用:
CALLBACK_ARGS_2(user_app_callbacks.app_on_connection, conidx, param)
其中CALLBACK_ARGS_2为:
#define CALLBACK_ARGS_2(cb, arg1, arg2) {
if (cb != NULL) cb(arg1, arg2);}
这样的好处是,修改程序时,调用方法固定,只需要改底层。
边栏推荐
- 【Promise】Promise 使用 / 回调地狱问题 async-await /宏队列与微队列
- Architect's talk [excerpt]
- MySQL:事务的概念 | ACID特性 | 事务并发存在的问题 | 事务处理命令
- The second bullet of FPGA development: running water lamp experiment
- The third bullet of FPGA development: button control LED experiment
- /usr/bin/ld: 找不到 -lLibUVC::UVCShared
- 纯c语言简单的写日志文件方法,gcc编译即可
- pip3升级后报错f“pip[sys.version_info.major)“
- Canvas image drawing (with zoom in, zoom out and drag functions)
- RestTemplate
猜你喜欢

FPGA development fourth bullet: touch button to control LED light experiment

Canvas image drawing (with zoom in, zoom out and drag functions)

redis基础常识、数据类型及基本命令

E-commerce data warehouse notes 1 (data warehouse concept, project requirements and architecture design, data generation module)

FPGA开发第三弹:按键控制LED实验

Transport layer (UDP protocol, TCP protocol three-way handshake, four-way wave)

Recursion: Understanding and Applying

面试官:如果要存 IP 地址,用什么数据类型比较好?很多人都会答错

微服务系列一:微服务的优势与劣势

Learning salient boundary feature for anchor-free temporal action localization AFSD阅读笔记
随机推荐
The network layer first
ansible当中模块的使用
Backpack Theory 01 Backpack
《C陷阱与缺陷》之“语义”陷阱——数组越界导致的程序死循环问题
QT不同子类间共享变量,教你简单、规范的方法
The server gets the user ip
数组的创建以及常见的方法
【C语言】内存函数
HPC Technology: Analysis of MPICH Implementation Principle
传输层(UDP协议,TCP协议三次握手、四次挥手)
LeetCode刷题笔记:206.反转链表(递归方法解决)
DCDC电源方案设计踩坑
Heavy Live | ORB-SLAM3 Series Code Explanation: Key Frames Topic 1
pip3升级后报错f“pip[sys.version_info.major)“
二分查找(搜索区间为左闭右开)
A Pursuit of Temporal Accuracy in General Activity Detection TAG论文阅读笔记
一些零碎知识点的索引
网络安全笔记2——单钥密码体制
同态加密:分圆多项式简介
为什么Move将超越Solidity成为主流编程语言?