如何在一个 linux 内核模块中定义一个函数并在另一个内核模块中使用它? [英] How to define a function in one linux kernel module and use it in another?

查看:24
本文介绍了如何在一个 linux 内核模块中定义一个函数并在另一个内核模块中使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为内核开发了两个简单的模块.现在我想在一个模块中定义一个函数,然后在另一个模块中使用它.

I developed two simple modules to the kernel. Now i want to define a function in one module and after that use it in the other.

我该怎么做?

只是在其他模块中定义函数和调用者没有问题?

Just define the function and caller in the other module without problems?

推荐答案

module1.c中定义:

#include <linux/module.h>

int fun(void);
EXPORT_SYMBOL(fun);

int fun(void)
{
    /* ... */
}

并在module2.c中使用:

extern int fun(void);

这篇关于如何在一个 linux 内核模块中定义一个函数并在另一个内核模块中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆