这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 请教在linux下的编译问题

共1条 1/1 1 跳转至

请教在linux下的编译问题

菜鸟
2004-12-20 01:50:57     打赏

我写了一个char的驱动程序,在rad-hat(2.7)在编译

file_operations时出现了问题

static struct file_operations buf_fops = { read: buf_read, write: buf_write, open: buf_open,

release: buf_release,

} ;

会出现一下问题:

[root@localhost buf]# make source='buf.c' object='buf.o' libtool=no depfile='.deps/buf.Po' tmpdepfile='.deps/buf.TPo' depmode=gcc3 /bin/sh ./depcomp gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"buf\" -DVERSION=\"1.0\" -I. -I. -g -O2 -c `test -f 'buf.c' || echo './'`buf.c buf.c:29:25: asm/uaccess.h: No such file or directory In file included from /usr/include/linux/bitops.h:69, from /usr/include/asm/system.h:7, from buf.c:30: /usr/include/asm/bitops.h:333:2: warning: #warning This includefile is not available on all architectures. /usr/include/asm/bitops.h:334:2: warning: #warning Using kernel headers in userspace. buf.c:50: warning: `struct file' declared inside parameter list buf.c:50: warning: its scope is only this definition or declaration, which is probably not what you want buf.c:55: warning: `struct file' declared inside parameter list buf.c:59: warning: `struct file' declared inside parameter list buf.c:59: warning: `struct inode' declared inside parameter list buf.c:64: warning: `struct file' declared inside parameter list buf.c:64: warning: `struct inode' declared inside parameter list buf.c:70: variable `buf_fops' has initializer but incomplete type buf.c:73: unknown field `read' specified in initializer buf.c:73: warning: excess elements in struct initializer buf.c:73: warning: (near initialization for `buf_fops') buf.c:75: unknown field `write' specified in initializer buf.c:75: warning: excess elements in struct initializer buf.c:75: warning: (near initialization for `buf_fops') buf.c:81: unknown field `open' specified in initializer buf.c:81: warning: excess elements in struct initializer buf.c:81: warning: (near initialization for `buf_fops') buf.c:83: unknown field `release' specified in initializer buf.c:83: warning: excess elements in struct initializer buf.c:83: warning: (near initialization for `buf_fops') buf.c:70: storage size of `buf_fops' isn't known make: *** [buf.o] Error 1 即read,write,open,release不被识别。

于是我用另外一种定义形式,即file_operations中没用到的函数都加上了Null。但

buf.c:70: variable `buf_fops' has initializer but incomplete type buf.c:70: storage size of `buf_fops' isn't known

这两句错误还有。

而我把这个char驱动程序丢到uclinux的char目录下用arm交叉编译器则没事。

不知为什么?

我试过把生成的uclinux下生成的buf.o编译进内核却不能调用。

还有就是我用过timer里的一个结构体。编译时系统居然报timer.h中有语法错误。

百思不得其解。

望各位大哥,大侠帮我点拨一下。




关键词: 请教     linux     编译     问题     struct     buf    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]