我正在编写一个简单的linux驱动程序,它将接受通过CLI传递的消息,并且出现了不兼容的指针类型错误。
我的读取函数和file_operations结构:
ssize_t driver_read(struct file *filep, char *buffer, ssize_t len, loff_t *offset) {
printk(KERN_INFO "Write: %s\n", message);
return 0;
}
struct file_operations fops = {
write: driver_write,
read: driver_read
};
当我尝试编译代码时,出现以下错误:
error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
read: driver_read
根据此处的另一篇文章,读取函数的返回类型应该是ssize_t,但我仍然遇到此错误。