dereferencing pointer to incomplete type错误的解决办法

今天在用make编译驱动程序时出现以下错误:

static struct task_struct *task;

出错原因主要在current上,宏current定义在arch/.../include/asm/current.h中。编译器不知道task_struct的具体定义,因此,无法解引用current,无法获知其成员pid、comm、flags的类型,才报“dereferencing pointer to incomplete type” task_struct定义在<linux/sched.h>中。在源文件头,加上#include <linux/sched.h>,即可解决问题!
“dereferencing pointer to incomplete type”错误,大多也是因为不知道struct/class/emun/union等的定义而引起的。

总结:对于“dereferencing pointer to incomplete type”错误,多数情况都是头文件引起的。。。

posted @ 2021-03-26 18:28  董大轩  阅读(3995)  评论(0编辑  收藏  举报