c - 编译 linux 内核时无法识别 list_head

标签 c linux list

我正在编译内核的修改版本,其中包含我编写的 C 程序。我是新手,我无法摆脱这个错误:

错误:未知类型名称“list_head”;您是说“rcu_head”吗?

以下是导致错误行的行:

//directives
#include <linux/sched.h>
#include <linux/list.h>
#include <linux/sched/task.h>
#include <asm-generic/barrier.h>
#include <linux/resource.h>

#define set_task_state(tsk, state_value)            \
    do {                            \
        (tsk)->task_state_change = _THIS_IP_;       \
        smp_store_mb((tsk)->state, (state_value));      \
    } while (0)

#define PROC_NUM 50
#define MILSEC_GAP 2

*(delta_entry) get_delta_entry(int num, *linked_list);
int get_delta_time(list_head *linked_list, delta_entry *de, int max);

我知道 list.h 包括定义 list_head 的 types.h。我做错了什么?

最佳答案

看了types.h,在我看来问题是这样的:list_head 是结构标记的名称,而不是类型。所以你需要写 struct list_head ... 而不是简单的 list_head ...。换句话说,函数原型(prototype)应该是

int get_delta_time(struct list_head *linked_list, delta_entry *de, int max);

无论何时你想要一个变量,你都需要将它声明为

struct list_head head;
head.next = ...

http://c-faq.com/struct/typedef.htmlhttp://c-faq.com/struct/impltypedef.html

关于c - 编译 linux 内核时无法识别 list_head,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56692079/

相关文章:

c-copy_to_user : how to read a struct type value of kernel space in the user space?

python StopIteration 与生成器和列表

c - 在哪里可以找到不同网络架构的基准?

c - 从叶子开始逐级修剪二叉流程树

c - 从函数中获取数组的计数

linux - Shell:在变量中打印 unicode 字

linux - 如何在 Bash 脚本中打印文件的大小(以千字节为单位)?

c - 多线程情况下修改栈

list - 如何在gsp页面$ {list.find {it.code == $ otherlist.code} .Desc}中显示此内容

java - 如何迭代2个数组列表