[-Werror,-Wincompatible-pointer-types]报错修改

文章讨论了在处理Linux内核驱动程序时遇到的编译错误,涉及到`structfile_operations`与`structproc_ops`类型不兼容的问题。作者指出在`goodix_tool.c`文件中使用了错误的参数类型,并提供了通过修改以适应`proc_fs.h`定义的解决方案。
摘要由CSDN通过智能技术生成

项目场景:

drivers/input/touchscreen/gt9xx/goodix_tool.c:200:56: error: incompatible pointer types passing ‘const struct file_operations *’ to parameter of type ‘const struct proc_ops *’ [-Werror,-Wincompatible-pointer-types]
goodix_proc_entry = proc_create(procname, 0666, NULL, &gtp_proc_ops);
^~~~~~~~~~~~~
./include/linux/proc_fs.h:109:122: note: passing argument to parameter ‘proc_ops’ here
struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
^
1 error generated.

在这里插入图片描述

看代码发现采用的结构体为实参file_operations
在这里插入图片描述
实际上报错上的看代码发现proc_fs.h采用的结构体形参为
在这里插入图片描述

自己修改
在这里插入图片描述

编译通过

  • 14
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值