我想了解这个错误。打印进程的UID,代码:
printk(KERN_INFO "User ID = %dn", (task)->cred->uid);
错误:
error: dereferencing pointer to incomplete type ‘const struct cred’
这很简单:编译器告诉您类型struct cred
是不完整的。换句话说,编译器不知道它的定义,因此它不知道是否存在uid
字段,也不知道该字段在结构中的位置。因此,它无法编译该->uid
。
要解决此问题,只需包含struct cred
:的正确定义
#include <linux/cred.h>