Dereferencing pointer to incomplete type ‘const struct cred’

非 Y 不嫁゛ 提交于 2020-04-17 20:27:20

问题


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’

回答1:


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>


来源:https://stackoverflow.com/questions/61211757/dereferencing-pointer-to-incomplete-type-const-struct-cred

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!