C 错误:函数的隐式声明';创建"进程"读取"条目';[-Werror=隐式函数声明]
我试图在内核3.13上编译内核模块,但出现以下错误:C 错误:函数的隐式声明';创建"进程"读取"条目';[-Werror=隐式函数声明],c,linux,linux-kernel,kernel-module,C,Linux,Linux Kernel,Kernel Module,我试图在内核3.13上编译内核模块,但出现以下错误: error: implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration] #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) proc = proc_net_create(KAODV_QUEUE_PROC_FS_NAME, 0, kaodv_q
error: implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration]
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
proc = proc_net_create(KAODV_QUEUE_PROC_FS_NAME, 0, kaodv_queue_get_info);
#else
proc = create_proc_read_entry(KAODV_QUEUE_PROC_FS_NAME, 0, init_net.proc_net, kaodv_queue_get_info, NULL);
#endif
if (!proc) {
printk(KERN_ERR "kaodv_queue: failed to create proc entry\n");
return -1;
}
我用谷歌搜索了一下,没有找到任何回应。以下是引用此错误的代码部分:
error: implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration]
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
proc = proc_net_create(KAODV_QUEUE_PROC_FS_NAME, 0, kaodv_queue_get_info);
#else
proc = create_proc_read_entry(KAODV_QUEUE_PROC_FS_NAME, 0, init_net.proc_net, kaodv_queue_get_info, NULL);
#endif
if (!proc) {
printk(KERN_ERR "kaodv_queue: failed to create proc entry\n");
return -1;
}
#if(LINUX版本代码<内核版本(2,6,24))
proc=proc_net_create(KAODV_QUEUE_proc_FS_NAME,0,KAODV_QUEUE_get_info);
#否则
proc=create_proc_read_条目(KAODV_QUEUE_proc_FS_NAME,0,init_net.proc_net,KAODV_QUEUE_get_info,NULL);
#恩迪夫
如果(!proc){
printk(KERN_ERR“kaodv_队列:无法创建进程项\n”);
返回-1;
}
我能得到帮助吗?我真的不知道怎么了。可能是内核3.13需要一个补丁。我在某个地方(在内核3.10上)读到内核需要补丁。有人能告诉我在哪里可以得到3.13内核补丁来最终解决这个问题吗。感谢此错误是因为您没有显式包含声明函数的标头,并且编译器为您隐式地“包含”,这会引发警告。标志'-Werror'使编译器将警告视为错误。尝试添加:
#包括
另外:
create\u proc\u read\u entry
是一个不推荐使用的函数
请看一下:Linux 3.9中的
static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
umode_t mode,
struct proc_dir_entry *base,
read_proc_t *read_proc,
void * data
) { return NULL; }
在Linux 3.10中
static inline struct proc_dir_entry *proc_create(const char *name,
umode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops
)
因此,将
create\u proc\u read\u entry()
更改为proc\u create()
,并将5个参数更改为4个参数。然后它就可以工作了。在您的linux 3.13版中,已删除此方法,而不是使用proc\u create或proc\u create\u data。您可以使用此API
struct proc_dir_entry *proc_create_data(const char *, umode_t,
struct proc_dir_entry *,
const struct file_operations *,
void *);
static inline struct proc_dir_entry *proc_create(
const char *name, umode_t mode, struct proc_dir_entry *parent,
const struct file_operations *proc_fops);
错误是因为您没有显式地包含声明函数的头,并且编译器为您隐式地“包含”,这会引发警告。标志'-Werror'使编译器将警告视为错误。尝试添加:
#include
@braindf:我们不做这个回答,因为它是答案。另外:create\u proc\u read\u entry
是一个不推荐使用的函数。可能重复感谢您的回复。因此,我的标题中已经包含了#include。我将检查不推荐使用的函数