繁体   English   中英

取消引用指向不完整类型'const struct cred'的指针

[英]Dereferencing pointer to incomplete type ‘const struct cred’

我想了解这个错误。 打印进程的UID,代码:

printk(KERN_INFO "User ID = %d\n", (task)->cred->uid);

错误:

error: dereferencing pointer to incomplete type ‘const struct cred’

这很简单:编译器告诉您类型struct cred不完整。 换句话说,编译器不知道它的定义,因此它不知道是否有一个uid字段或该字段在结构中的位置。 因此它无法编译该->uid

要解决此问题,只需包含struct cred的正确定义:

#include <linux/cred.h>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM