gpt4 book ai didi

ubuntu - 如何修复错误 : implicit declaration of function ‘setup_timer’

转载 作者:行者123 更新时间:2023-12-04 18:29:47 25 4
gpt4 key购买 nike

正在尝试为 USB 声卡 Line6 UX2 编译 linux 核心模块。
从 repo 获取代码并尝试制作。 repo 没有 ./configure

使产生错误:

line6linux-code-r1108/driver/trunk/driver.c:169:2: error: implicit declaration of function ‘setup_timer’; did you mean ‘del_timer’? [-Werror=implicit-function-declaration]
setup_timer(timer, function, data);
^~~~~~~~~~~
del_timer

C 函数 setup_timer() 在 linux linux-headers 包中声明。目前是 linux-headers-4.18.0-16
当然它安装在默认位置/usr/src/

产生错误的代码(driver.c):

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/usb.h>

#include <sound/core.h>
#include <sound/initval.h>

#include "capture.h"
#include "driver.h"
#include "midi.h"
#include "playback.h"

... some code here

/*
Setup and start timer.
*/
void line6_start_timer(struct timer_list *timer, unsigned long msecs,
void (*function)(unsigned long), unsigned long data)
{
setup_timer(timer, function, data); // <-- string 169
mod_timer(timer, jiffies + msecs_to_jiffies(msecs));
}
EXPORT_SYMBOL_GPL(line6_start_timer);

所以显然编译器找不到linux头文件。我该如何解决?

同样基于 INSTALL 文件,驱动程序是为内核版本 linux-headers-2.6.x 编写的,现在它是 4.18.0-16。

更多来自 INSTALL:对于其他发行版,请查阅文档以找出您必须安装的软件包。

一切都丢失了吗?

操作系统 Ubuntu 18.10
Linux 4.18.0-16-generic#17-Ubuntu SMP Fri Feb 8 00:06:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

最佳答案

在较新版本的 Linux 内核中,setup_timer函数被称为 timer_setup .

请注意,回调函数的类型在重新发布的版本中已更改。现在回调接受指向 timer_list 的指针结构本身。

在这篇 LWN 文章中查看更多信息:https://lwn.net/Articles/735887/ .

关于ubuntu - 如何修复错误 : implicit declaration of function ‘setup_timer’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55333646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com