/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等的定义而引起的。