if (!vfifo_devices[i].r_handle||!vfifo_devices[i].w_handle){
printk(KERN_WARNING "vfifo: can 't register vfifo device nr %i\n ",i);
}
#endif
}
#ifdef VFIFO_DEBUG
create_proc_read_entry( "vfifo ",0,NULL,vfifo_read_mem,NULL);
#endif
return 0;
}
static void __exit vfifo_cleanup_module(void)
{
int i;
devfs_unregister_chrdev(vfifo_major, "vfifo ");
#ifdef VFIFO_DEBUG
remove_proc_entry( "vfifo ",NULL);
#endif
if (vfifo_devices){
for (i=0;i <vfifo_nr_devs;i++){
if (vfifo_devices[i].base)
kfree(vfifo_devices[i].base);
devfs_unregister(vfifo_devices[i].r_handle);
devfs_unregister(vfifo_devices[i].w_handle);
}
kfree(vfifo_devices);
devfs_unregister(vfifo_devfs_dir);
}
}
module_init(vfifo_init_module);
module_exit(vfifo_cleanup_module);作者: asd123vae 时间: 2011-05-06 20:19
在Ubuntu中的vi编辑器编译后、出现如下的错误:(我新手、完全看不懂啊~~~求助)
xianan@xianan-desktop:~$ gcc -c vfifo.c -D_KERNEL_-DMODULE -o2 -g -Wall
<command-line>: warning: missing whitespace after the macro name
vfifo.c:8:29: error: linux/config.h: No such file or directory
vfifo.c:9:29: error: linux/module.h: No such file or directory
vfifo.c:11:27: error: linux/slab.h: No such file or directory
vfifo.c:13:30: error: linux/proc_fs.h: No such file or directory
In file included from /usr/include/asm/fcntl.h:1,
from /usr/include/linux/fcntl.h:4,
from vfifo.c:16:
/usr/include/asm-generic/fcntl.h:96: error: expected specifier-qualifier-list before ‘pid_t’
vfifo.c:17:27: error: linux/init.h: No such file or directory
vfifo.c:19:28: error: asm/uaccess.h: No such file or directory
vfifo.c:20:27: error: asm/system.h: No such file or directory
vfifo.c:30:38: error: linux/devfs_fs_kernel.h: No such file or directory
vfifo.c:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vfifo_devfs_dir’
vfifo.c:35: error: expected ‘)’ before string constant
vfifo.c:36: error: expected ‘)’ before string constant
vfifo.c:37: error: expected ‘)’ before string constant
vfifo.c:38: error: expected declaration specifiers or ‘...’ before string constant
vfifo.c:38: warning: data definition has no type or storage class
vfifo.c:38: warning: type defaults to ‘int’ in declaration of ‘MODULE_AUTHOR’
vfifo.c:41: error: expected specifier-qualifier-list before ‘wait_queue_head_t’
vfifo.c:55: warning: ‘struct file’ declared inside parameter list
vfifo.c:55: warning: its scope is only this definition or declaration, which is probably not what you want
vfifo.c:55: warning: ‘struct inode’ declared inside parameter list
vfifo.c: In function ‘vfifo_open’:
vfifo.c:58: warning: implicit declaration of function ‘MINOR’
vfifo.c:58: error: dereferencing pointer to incomplete type
vfifo.c:59: error: dereferencing pointer to incomplete type
vfifo.c:61: error: expected expression before ‘=’ token
vfifo.c:64: error: dereferencing pointer to incomplete type
vfifo.c:66: error: dereferencing pointer to incomplete type
vfifo.c:68: warning: implicit declaration of function ‘down_interruptible’
vfifo.c:68: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c:69: error: ‘ERESTARTSYS’ undeclared (first use in this function)
vfifo.c:69: error: (Each undeclared identifier is reported only once
vfifo.c:69: error: for each function it appears in.)
vfifo.c:70: error: ‘Vfifo_Dev’ has no member named ‘base’
vfifo.c:71: error: ‘Vfifo_Dev’ has no member named ‘base’
vfifo.c:71: warning: implicit declaration of function ‘kmalloc’
vfifo.c:71: error: ‘GFP_KERNEL’ undeclared (first use in this function)
vfifo.c:72: error: ‘Vfifo_Dev’ has no member named ‘base’
vfifo.c:73: warning: implicit declaration of function ‘up’
vfifo.c:73: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c:76: error: ‘Vfifo_Dev’ has no member named ‘buffersize’
vfifo.c:77: error: ‘Vfifo_Dev’ has no member named ‘len’
vfifo.c:77: error: ‘Vfifo_Dev’ has no member named ‘start’
vfifo.c:79: error: dereferencing pointer to incomplete type
vfifo.c:79: error: ‘fmode_t’ undeclared (first use in this function)
vfifo.c:79: error: expected ‘)’ before numeric constant
vfifo.c:80: error: ‘Vfifo_Dev’ has no member named ‘readers’
vfifo.c:81: error: dereferencing pointer to incomplete type
vfifo.c:81: error: expected ‘)’ before numeric constant
vfifo.c:81: error: ‘Vfifo_Dev’ has no member named ‘writers’
vfifo.c:82: error: dereferencing pointer to incomplete type
vfifo.c:83: error: ‘MOD_INC_USE_COUNT’ undeclared (first use in this function)
vfifo.c:84: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c: At top level:
vfifo.c:89: warning: ‘struct file’ declared inside parameter list
vfifo.c:89: warning: ‘struct inode’ declared inside parameter list
vfifo.c: In function ‘vfifo_release’:
vfifo.c:91: error: dereferencing pointer to incomplete type
vfifo.c:92: warning: implicit declaration of function ‘down’
vfifo.c:92: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c:93: error: dereferencing pointer to incomplete type
vfifo.c:93: error: ‘fmode_t’ undeclared (first use in this function)
vfifo.c:93: error: expected ‘)’ before numeric constant
vfifo.c:94: error: ‘Vfifo_Dev’ has no member named ‘readers’
vfifo.c:95: error: dereferencing pointer to incomplete type
vfifo.c:95: error: expected ‘)’ before numeric constant
vfifo.c:96: error: ‘Vfifo_Dev’ has no member named ‘writers’
vfifo.c:97: warning: implicit declaration of function ‘wake_up_interruptible’
vfifo.c:97: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c:99: error: ‘Vfifo_Dev’ has no member named ‘readers’
vfifo.c:99: error: ‘Vfifo_Dev’ has no member named ‘writers’
vfifo.c:99: error: ‘Vfifo_Dev’ has no member named ‘len’
vfifo.c:100: warning: implicit declaration of function ‘kfree’
vfifo.c:100: error: ‘Vfifo_Dev’ has no member named ‘base’
vfifo.c:101: error: ‘Vfifo_Dev’ has no member named ‘base’
vfifo.c:103: error: ‘Vfifo_Dev’ has no member named ‘sem’
vfifo.c:104: error: ‘MOD_DEC_USE_COUNT’ undeclared (first use in this function)
vfifo.c: At top level:
vfifo.c:107: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vfifo_read’
vfifo.c:162: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vfifo_write’
vfifo.c:215: error: expected declaration specifiers or ‘...’ before ‘poll_table’
vfifo.c:215: warning: ‘struct file’ declared inside parameter list
vfifo.c: In function ‘vfifo_poll’:
vfifo.c:217: error: dereferencing pointer to incomplete type
vfifo.c:219: warning: implicit declaration of function ‘poll_wait’
vfifo.c:219: error: ‘Vfifo_Dev’ has no member named ‘rdq’
vfifo.c:219: error: ‘wait’ undeclared (first use in this function)
vfifo.c:220: error: ‘Vfifo_Dev’ has no member named ‘wrq’
vfifo.c:221: error: ‘Vfifo_Dev’ has no member named ‘len’
vfifo.c:222: error: ‘Vfifo_Dev’ has no member named ‘len’
vfifo.c:222: error: ‘Vfifo_Dev’ has no member named ‘buffersize’
vfifo.c: At top level:
vfifo.c:227: error: variable ‘vfifo_fops’ has initializer but incomplete type
vfifo.c:228: error: unknown field ‘read’ specified in initializer
vfifo.c:228: error: ‘vfifo_read’ undeclared here (not in a function)
vfifo.c:228: warning: excess elements in struct initializer
vfifo.c:228: warning: (near initialization for ‘vfifo_fops’)
vfifo.c:229: error: unknown field ‘write’ specified in initializer
vfifo.c:229: error: ‘vfifo_write’ undeclared here (not in a function)
vfifo.c:229: warning: excess elements in struct initializer
vfifo.c:229: warning: (near initialization for ‘vfifo_fops’)
vfifo.c:230: error: unknown field ‘poll’ specified in initializer
vfifo.c:230: warning: excess elements in struct initializer
vfifo.c:230: warning: (near initialization for ‘vfifo_fops’)
vfifo.c:231: error: unknown field ‘open’ specified in initializer
vfifo.c:231: warning: excess elements in struct initializer
vfifo.c:231: warning: (near initialization for ‘vfifo_fops’)
vfifo.c:232: error: unknown field ‘release’ specified in initializer
vfifo.c:232: warning: excess elements in struct initializer
vfifo.c:232: warning: (near initialization for ‘vfifo_fops’)
vfifo.c:236: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vfifo_init_module’
vfifo.c:281: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vfifo_cleanup_module’
vfifo.c:300: warning: data definition has no type or storage class
vfifo.c:300: warning: type defaults to ‘int’ in declaration of ‘module_init’
vfifo.c:300: warning: parameter names (without types) in function declaration
vfifo.c:301: warning: data definition has no type or storage class
vfifo.c:301: warning: type defaults to ‘int’ in declaration of ‘module_exit’
vfifo.c:301: warning: parameter names (without types) in function declaration作者: asd123vae 时间: 2011-05-06 20:20
希望哪位高手帮我解决下、谢谢了。