阅读:1209回复:3
内核编程时怎么处理版本问题?(给20分)
我在进行内核编程时,连最简单的hello.c程序都出现错误:
/* gcc -c hello.c * insmod hello.o * rmmod hello.o */ #define MODULE #include <linux/module.h> void init_module(void) { printk(\"hello,world\\n\"); return 0; } void cleanup_module(void) { printk(\"goodbye cruel world\\n\"); } 编译后,出现以下错误: [root@gigimao test]# gcc -c hello.c In file included from hello.c:7: /usr/include/linux/module.h:60: parse error before `atomic_t\' /usr/include/linux/module.h:60: warning: no semicolon at end of struct or union /usr/include/linux/module.h:60: warning: no semicolon at end of struct or union /usr/include/linux/module.h:62: parse error before `}\' /usr/include/linux/module.h:62: warning: data definition has no type or storage class /usr/include/linux/module.h:91: parse error before `}\' noname1.c: In function `init_module\': noname1.c:12: warning: `return\' with a value, in function returning void 请高手看看,这是什么问题? :( |
|
沙发#
发布于:2003-05-09 21:24
你用的是哪个版本的linux?如果是redhat8。0的话,用如下命令即可,如果用的是其他版本,只要修改内核文件的路径即可。
gcc -D__KERNEL__ -D__SMP__ -DMODULE -DEXPORT_SYMTAB -c -I/usr/src/linux-2.4.18-14/include -o filename.o filename.c |
|
板凳#
发布于:2003-05-10 21:53
一般只要该这个目录 -I/usr/src/linux-2.4.18-14/include
不同内核的话,模块中加以判断 |
|
|
地板#
发布于:2003-05-10 23:21
非常感谢楼上的各位,问题已经解决了。 :)
|
|