今天在用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”錯誤,多數情況都是頭文件引起的。。。