简体   繁体   中英

Dereferencing pointer to incomplete type ‘const struct cred’

I want to understand this error. Printing UID of a process, code:

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. 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. Therefore it cannot compile that ->uid .

To fix this, simply include a correct definition of struct cred :

#include <linux/cred.h>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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