小编Fad*_*sry的帖子

内核模块编译错误:函数声明不是原型[-Werror = strict-prototypes]

此代码:Linux内核模块,可直接控制PS/2键盘的LED(Num Lock,Caps Lock和Scroll Lock)

#include <linux/module.h>
#include <linux/kernel.h>

int check_bit(unsigned char status, int i) {
    return (status & (1<<(i)));
}

unsigned char kbd_read_status() {  // <== ERROR first appears on this line
    return inb(0x64);
}

unsigned char kbd_read_data() {
    unsigned char status;   
    do
    {
        status = kbd_read_status();
    }
    while(!check_bit(status, 0));
    return inb(0x60);
}
Run Code Online (Sandbox Code Playgroud)

运行makefile时:

make -C /lib/modules/3.19.0-15-generic/build M=/home/fyousry/Desktop/hellokernel modules
make[1]: Entering directory '/usr/src/linux-headers-3.19.0-15-generic'
  CC [M]  /home/fyousry/Desktop/hellokernel/New.o
/home/fyousry/Desktop/hellokernel/New.c:9:15: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
 unsigned char kbd_read_status() {
               ^
/home/fyousry/Desktop/hellokernel/New.c:13:15: …
Run Code Online (Sandbox Code Playgroud)

c linux makefile

6
推荐指数
1
解决办法
4836
查看次数

标签 统计

c ×1

linux ×1

makefile ×1