/usr/src/linux-headers-4.9.0-3-common/arch/x86/include/asm/uaccess.h:33:26: error: dereferencing pointer to incomplete type ‘struct task_struct’
#define get_fs() (current->thread.addr_limit)
出錯原因主要在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等的定義而引起的。
原文鏈接:https://blog.csdn.net/zbqwxy/article/details/8697896