Thi*_*ruG 7 c compiler-errors linux-kernel
我正在学习为初学者编写Linux内核模块.我要做的是使用DFS算法将每个任务及其子进程写入内核日志.但是当我使用编译代码时Makefile,它显示上面的错误:
function declaration isn’t a prototype [-Werror=strict-prototypes]
struct task_struct *current;
Run Code Online (Sandbox Code Playgroud)
它task_struct在函数DFS中指出了关键字.这是我的代码:
# include <linux/init.h>
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/sched.h>
# include <linux/list.h>
void DFS (struct task_struct *task)
{
struct task_struct *current;
struct list_head *list;
list_for_each (list, &task->children)
{
current = list_entry(list, struct task_struct, sibling);
printk(KERN_INFO "%d\t%d\t%s \n", (int)current->state, current->pid, current->comm);
if (current != NULL)
{
DFS(current);
}
}
}
int DFS_init(void)
{
printk(KERN_INFO "Loading the Second Module...\n");
printk(KERN_INFO "State\tPID\tName\n");
DFS(&init_task);
return 0;
}
void DFS_exit(void)
{
printk(KERN_INFO "Removing the Second Module...\n");
}
Run Code Online (Sandbox Code Playgroud)
谁知道如何解决这个问题?