简体   繁体   English

我可以在内核模块中调用在内核源文件的另一个头文件中定义的静态内联函数吗?

[英]In kernel module can I call static inline function defined in another header file of the kernel source?

I will try to make the question clear. 我会尽力弄清楚这个问题。 I am developing a loadable kernel module and just wondering whether I can call a static inline function defined in another header file of the Linux kernel source. 我正在开发一个可加载的内核模块,只是想知道是否可以调用在Linux内核源代码的另一个头文件中定义的静态内联函数。 I understand that the static keyword makes the function restricted within the scope of the compilation unit(ie a C file). 我知道static关键字将功能限制在编译单元(即C文件)的范围内。 But if I include the header file where the static inline function is defined, can I use it in my module? 但是,如果我包括在其中定义了静态内联函数的头文件,是否可以在我的模块中使用它?

Whether I can call a static inline function defined in another header file of the Linux kernel source?? 是否可以调用在Linux内核源的另一个头文件中定义的静态内联函数?

Yes. 是。 Possible. 可能。 kmalloc() is an example for it. kmalloc()就是一个例子。 This function is defined in include/linux/slab.h as a static inline function. 该函数在include / linux / slab.h中定义为static inline函数。 Suggest to read this post which explains why static inline is used in header files. 建议阅读这篇文章, 文章解释了为什么在头文件中使用静态内联。

References 参考
http://lxr.free-electrons.com/source/include/linux/slab.h#L452 http://lxr.free-electrons.com/source/include/linux/slab.h#L452
What's the difference between "static" and "static inline" function? “静态”和“静态内联”功能有什么区别?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM