linux动态库(二)

上篇文章呈现了linux下动态库的一个简单实现,其接口按通用的方式导出,测试程序可以直接调用,本篇展现一个导出函数列表的方式,可以通过函数列表实现对接口的调用

头文件

/*
  @ File Name: calc.h
  @ Author: hw
  @ Mail: feiyelove@163.com
  @ Created Time: 2015-07-01 14:42:00
*/

#ifndef _CALC_H_
#define _CALC_H_

#ifdef __cplusplus
extern "C"
{
#endif

int add(int a, int b);
int sub(int a, int b);

typedef struct _CALC_FUNCLIST {
        int version;
        int (*fnadd)(int a, int b);
        int (*fnsub)(int a, int b);
}CALC_FUNCLIST;
typedef CALC_FUNCLIST* CALC_FUNCLIST_PTR;
typedef CALC_FUNCLIST_PTR* CALC_FUNCLIST_PTR_PTR;

int GetFunclist(CALC_FUNCLIST_PTR_PTR ppFuncList);

typedef void (*GET_FUNCLIST_PTR)(CALC_FUNCLIST_PTR_PTR ppFuncList);

#ifdef __cplusplus
} 
#endif        

#endif

源文件

/*
  @ File Name: calc.c
  @ Author: hw
  @ Mail: feiyelove@163.com
  @ Created Time: 2015-07-01 14:39:26
*/

#include "calc.h"

#ifdef __cplusplus
extern "C"
{
#endif

int add(
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值