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

取消引用指向不完整类型的指针‘;const struct cred’;,c,linux-kernel,C,Linux Kernel,我想了解这个错误。打印进程的UID,代码: printk(KERN_INFO "User ID = %d\n", (task)->cred->uid); 错误: 错误:取消引用指向不完整类型“const struct cred”的指针 这很简单:编译器告诉您类型struct cred不完整。换句话说,编译器不知道它的定义,因此它不知道是否存在uid字段,或者该字段在结构中的位置。因此,它无法编译->uid 要解决此问题,只需包含正确的struct cred: #include &l

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

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

错误:取消引用指向不完整类型“const struct cred”的指针

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

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

#include <linux/cred.h>
#包括

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

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

#include <linux/cred.h>
#包括