[英]Dereferencing pointer to incomplete type ‘const struct cred’
I want to understand this error.我想了解这个错误。 Printing UID of a process, code:
打印进程的UID,代码:
printk(KERN_INFO "User ID = %d\n", (task)->cred->uid);
The error:错误:
error: dereferencing pointer to incomplete type ‘const struct cred’
It's pretty straightforward: the compiler is telling you that the type struct cred
is incomplete.这很简单:编译器告诉您类型
struct cred
不完整。 In other words, the compiler does not know its definition, and therefore it does not know whether there is a uid
field or where in the struct the field is located.换句话说,编译器不知道它的定义,因此它不知道是否有一个
uid
字段或该字段在结构中的位置。 Therefore it cannot compile that ->uid
.因此它无法编译该
->uid
。
To fix this, simply include a correct definition of struct cred
:要解决此问题,只需包含
struct cred
的正确定义:
#include <linux/cred.h>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.