Linux 5.10版本添加带参数模块编译报错问题

记录一下今天hello world级添加Linux模块中遇到的问题

  1.  问题1 “error: ‘param_ops_char’ undeclared here (not in a function); did you mean ‘param_ops_charp’?”
    
     这里指明了函数使用的错误
     module_param(who,char,0644);
     这是原本的写法,不知道是不是因为版本更迭而导致了module_param		()方法中无法识别char类型,要求更改为charp类型
     即更改为module_param(who,charp,0644);即可
    
  2.  问题2	“./include/linux/moduleparam.h:150:27: error: expected ‘)’ before ‘&’ token”
    
     首先从进入到这个报错的文件中,这个文件在Linux包里
     (例如我的:/usr/src/linux-5.10.20/include/linux/moduleparam.h)
     找到报错的第150行,我原本的代码如下(我的初始代码就是这样)
     param_check_##type(name, &(value));  
     这里&(value)作为参数很明显不符合C的代码格式,将它改为&value即可。
    

Guess you like

Origin blog.csdn.net/weixin_48299611/article/details/115516098