记录下在学习Linux驱动的时候遇到的问题:
编译驱动遇到这样的报错:
error: expected declaration specifiers or ‘…’ before string constant
warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘MODULE_LICEVSE’
warning: function declaration isn’t a prototype
网上搜索出的结果是少了头文件:
#include<linux/modules.h>
但是我是有这个头文件的,后面发现注释掉:
MODULE_LICEVSE("GPL2"); //表示模块代码接受的软件许可协议,Linuxi内核遵循GPLV2开源协议,内核模块与linux内核保持一致即可。
就解决了该问题。