简体   繁体   English

Linux 内核模块中的头文件冲突

[英]Conflicting header files in Linux Kernel Module

I'm trying to write a Linux kernel module that uses first_net_device() from <linux/netdevice.h> and getsockname() from <sys/socket.h> .我正在尝试编写一个 Linux 内核模块,它使用<linux/netdevice.h> first_net_device()<sys/socket.h> getsockname() The problem at compile time is that these two header files have some duplicate definitions, resulting in a compilation failure.编译时的问题是这两个头文件有一些重复的定义,导致编译失败。 How do I solve this?我该如何解决这个问题? Thanks谢谢

The sys/socket.h header is not a kernel header. sys/socket.h头文件不是内核头文件。 When you try and add it to your module you'll almost certainly get errors because it's not part of the kernel.当您尝试将它添加到您的模块时,您几乎肯定会遇到错误,因为它不是内核的一部分。 Have a look at this answer for more details....看看这个答案了解更多细节......

Why can't we use C standard library functions in kernel development? 为什么内核开发中不能使用C标准库函数?

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

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