警告:从不兼容的指针类型传递参数1

时间:2015-02-20 03:43:30

标签: c linux pointers struct kernel

我正在使用c对Linux上的内核模块的结构做一些工作,我似乎无法获得指向结构中对象的指针。我的代码如下:

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>

struct list_head *list;

/* performs a depth-first traversal of the list of tasks in the system. */
void print_task_info(struct task_struct *task) {

    for_each_process(task){

        printk("%s, %d, %d \n", task->comm, (int)task->state, task->pid);
    }
    list_for_each(list, &init_task.children){
        print_task_info(&task->children);
        task = list_entry(list, struct task_struct, sibling);
    }
}

当我对print_task_info()进行递归调用时出现问题。我尝试添加很多不同的东西,使用一元*,没有符号,投射,没有一个对我有用。你有什么建议吗?我搜索了但是我无法在任何有关结构的C语言文档中找到有关此内容的任何资源,如何将其作为指针,所以当我用完其他选项时我来到这里。

0 个答案:

没有答案