error: 'TASK_UNINTERRUPTIBLE' undeclared (first use in this function)和error: 'TASK_NORMAL' undeclare



在编写一个阻塞型驱动程序时,编译出现错误。

root@ubuntu:/home/linuxsystemcode/devicedriver/KEY/HDKEY# make
/home/linuxsystemcode/devicedriver/KEY/HDKEY/key.c:43:
error: 'TASK_NORMAL' undeclared (first use in this function)
/home/linuxsystemcode/devicedriver/KEY/HDKEY/key.c:43:
error: (Each undeclared identifier is reported only once
/home/linuxsystemcode/devicedriver/KEY/HDKEY/key.c:43:
error: for each function it appears in.)

/home/linuxsystemcode/devicedriver/KEY/HDKEY/key.c:77:
error: 'TASK_UNINTERRUPTIBLE' undeclared (first use in this function)

1.经过查找内核代码,我首先加入库文件包含进去

2.再次make编译出现新的错误。

#make

/home/linuxsystemcode/devicedriver/KEY/HDKEY/key.c:100: error: conflicting types for 'key_init'
include/linux/key.h:308: note: previous declaration of 'key_init' was here

想到可能是key_init()函数和内核可能冲突,立即使用Soure Insight 内核源码查找
key_init,结果内核中定义
中有如下定义:#define key_init() do { } while(0)
修改驱动模块初始化函数key_init()的名称,重新编译,顺利通过。


你可能感兴趣的:(开发问题解决)