标题: 如何编写LINUX设备驱动程序 [打印本页] 作者: yyykkk1229 时间: 2008-08-07 10:18 标题: 如何编写LINUX设备驱动程序 http://www.it.com.cn/f/edu/0411/30/53811.htm
按照上面连接的范例想要编写设备驱动程序
得到如下错误,请教高手该如何修改
test.c:13: warning: `struct file' declared inside parameter list
test.c:13: warning: its scope is only this definition or declaration, which is probably not what you want
test.c:13: warning: `struct inode' declared inside parameter list
test.c: In function `read_test':
test.c:18: `VERIFY_WRITE' undeclared (first use in this function)
test.c:18: (Each undeclared identifier is reported only once
test.c:18: for each function it appears in.)
test.c:21: parse error before "for"
test.c: At top level:
test.c:30: warning: `struct file' declared inside parameter list
test.c:30: warning: `struct inode' declared inside parameter list
test.c:35: warning: `struct file' declared inside parameter list
test.c:35: warning: `struct inode' declared inside parameter list
test.c: In function `open_tibet':
test.c:37: `MOD_ING_USE_COUNT' undeclared (first use in this function)
test.c: At top level:
test.c:41: warning: `struct file' declared inside parameter list
test.c:41: warning: `struct inode' declared inside parameter list
test.c: In function `release_tibet':
test.c:43: union has no member named `usecount'
test.c: At top level:
test.c:46: variable `test_fops' has initializer but incomplete type
test.c:47: warning: excess elements in struct initializer
test.c:47: warning: (near initialization for `test_fops')
test.c:48: warning: excess elements in struct initializer
test.c:48: warning: (near initialization for `test_fops')
test.c:49: `write_test' undeclared here (not in a function)
test.c:49: warning: excess elements in struct initializer
test.c:49: warning: (near initialization for `test_fops')
test.c:50: warning: excess elements in struct initializer
test.c:50: warning: (near initialization for `test_fops')
test.c:51: warning: excess elements in struct initializer
test.c:51: warning: (near initialization for `test_fops')
test.c:52: warning: excess elements in struct initializer
test.c:52: warning: (near initialization for `test_fops')
test.c:53: warning: excess elements in struct initializer
test.c:53: warning: (near initialization for `test_fops')
test.c:54: `open_test' undeclared here (not in a function)
test.c:54: warning: excess elements in struct initializer
test.c:54: warning: (near initialization for `test_fops')
test.c:55: `release_test' undeclared here (not in a function)
test.c:55: warning: excess elements in struct initializer
test.c:55: warning: (near initialization for `test_fops')
test.c:56: warning: excess elements in struct initializer
test.c:56: warning: (near initialization for `test_fops')
test.c:57: warning: excess elements in struct initializer
test.c:57: warning: (near initialization for `test_fops')
test.c: In function `init_module':
test.c:64: parse error before '=' token
test.c:67: `KERN_INFO' undeclared (first use in this function)
test.c:67: parse error before string constant
/usr/include/linux/timer.h: At top level:
test.c:46: storage size of `test_fops' isn't known
有没有可能是因为我的库不包含有file_operations呀
麻烦你了,谢谢作者: dreamice 时间: 2008-08-07 14:41 标题: 回复 #11 yyykkk1229 的帖子 应该不是,你编译一下那个hello-1试一下,看能不能成功。作者: yyykkk1229 时间: 2008-08-07 14:44
那个是成功的...insmod可以加载模块作者: dreamice 时间: 2008-08-07 14:52 标题: 回复 #11 yyykkk1229 的帖子 老大,你怎么没有加#include <linux/kernel.h>阿?作者: yyykkk1229 时间: 2008-08-07 15:08
加了,依然不行,我重新编译了一下内核模块,错误发生了改变,但依然看不懂
test.c:7:25: asm/uaccess.h: No such file or directory
In file included from /usr/include/linux/fs.h:23,
from test.c:10:
/usr/include/linux/string.h:8:2: warning: #warning Using kernel header in userland!
In file included from /usr/include/linux/sched.h:14,
from /usr/include/linux/mm.h:4,
from test.c:11:
/usr/include/linux/timex.h:173: field `time' has incomplete type
/usr/include/linux/timex.h:188: confused by earlier errors, bailing out作者: dreamice 时间: 2008-08-07 15:13
错误1:没有找到这个文件asm/uaccess.h
错误2:Using kernel header in userland! 你的编译有问题,makefile可能写得不对,在用户空间引用内核头文件,这本身就可能造成错误。其它地方,可能是兼容性造成的错误。