【问题标题】:Dereferencing pointer to incomplete type ‘const struct cred’取消引用指向不完整类型“const struct cred”的指针
【发布时间】:2020-04-15 00:54:48
【问题描述】:

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

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

错误:

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

【问题讨论】:

    标签: c linux-kernel


    【解决方案1】:

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

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

    #include <linux/cred.h>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-25
      • 2016-09-05
      • 1970-01-01
      • 2013-03-11
      相关资源
      最近更新 更多