开发linux驱动程序问题?????????????????
我编写了如下代码:编译不通过,报下面的错误,我该如何解决呢??
#define MODULE
#include <linux/module.h>;
#include <linux/fs.h>;
#include <errno.h>;
static scull_major;
static ssize_t scull_read(struct file *file,char *buf,size_t count,loff_t *ppos)
{
return 0;
}
static ssize_t scull_write(struct file *file,const char *buf,size_t count,loff_t *ppos)
{
return 0;
}
static struct file_operations scull_fops={
owner: THIS_MODULE,
read: scull_read,
write: scull_write,
};
int init_module(void)
{
scull_major = register_chrdev(0,"scull",scull_fops);
if(scull_major<0)
{
printk("ERR: can't get major dev no\n"
return scull_major;
}
printk("Register dev is ok, scull_major is %d\n",scull_major);
return 0;
}
void cleanup_module(void)
{
int ret;
ret = unregister_chrdev(scull_major,"scull"
if(ret==-EINVAL)
printk("err\n"
printk("scull: good bye, ret = %d\n",ret);
}
编译报的错误
: gcc -c scull.c
scull.c:8: warning: `struct file' declared inside parameter list
scull.c:8: warning: its scope is only this definition or declaration, which is probably not what you want
scull.c:13: warning: `struct file' declared inside parameter list
scull.c:18: variable `scull_fops' has initializer but incomplete type
scull.c:19: unknown field `owner' specified in initializer
scull.c:19: warning: excess elements in struct initializer
scull.c:19: warning: (near initialization for `scull_fops')
scull.c:20: unknown field `read' specified in initializer
scull.c:20: warning: excess elements in struct initializer
scull.c:20: warning: (near initialization for `scull_fops')
scull.c:21: unknown field `write' specified in initializer
scull.c:21: warning: excess elements in struct initializer
scull.c:21: warning: (near initialization for `scull_fops')
scull.c: In function `init_module':
scull.c:27: `scull_fops' has an incomplete type
scull.c: At top level:
scull.c:18: storage size of `scull_fops' isn't known
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论