【发布时间】:2019-03-21 22:25:57
【问题描述】:
我正在开发一个 linux 内核模块。
头文件中定义了一个struct tcpsp_conn,如下:
struct tcpsp_conn {
...
struct timer_list timer; /* exp. timer*/
...
};
然后我声明一个指向结构的指针并尝试分配函数:
struct tcpsp_conn *cp;
cp->timer.function = tcpsp_conn_expire;
tcpsp_conn_expire 函数的定义方式与内核的 struct timer_list 中相同:
static void tcpsp_conn_expire(unsigned long data)
我不明白为什么会出现此错误: 错误:来自不兼容指针类型的赋值 [-Werror=incompatible-pointer-types] cp->timer.function = tcpsp_conn_expire;
看起来类型没有问题。
【问题讨论】:
标签: linux-kernel kernel-module