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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM