| 
 | 
 
这几天在学习动态加载内核模块,     写了一个最简单的“helloworld“模块, 编译的时候出了很多问题, 我用的是FC5, 2.6.15内核, gcc版本4.1.0, 编译环境与我正在使用的内核编译环境相同, 源码中包含的头文件是/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h。  
执行gcc -c helloworld.c, 错误提示如下: 
 
[root@localhost helloworld]# gcc -c helloworld.c 
In file included from /usr/include/linux/sched.h:13, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/linux/times.h:7: 错误:expected specifier-qualifier-list before ‘clock_t’ 
In file included from /usr/include/linux/sched.h:14, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/linux/timex.h:148: 错误:字段 ‘time’ 的类型不完全 
In file included from /usr/include/linux/signal.h:4, 
                 from /usr/include/linux/sched.h:25, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/asm/signal.h:107: 错误:expected specifier-qualifier-list before ‘sigset_t’ 
In file included from /usr/include/linux/signal.h:5, 
                 from /usr/include/linux/sched.h:25, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/asm/siginfo.h:48: 错误:expected specifier-qualifier-list before ‘clock_t’ 
In file included from /usr/include/linux/sched.h:65, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/linux/time.h:10: 错误:expected specifier-qualifier-list before ‘time_t’ 
/usr/include/linux/time.h:18: 错误:expected specifier-qualifier-list before ‘time_t’ 
In file included from /usr/include/linux/sched.h:69, 
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10, 
                 from helloworld.c:2: 
/usr/include/asm/processor.h:73: 错误:数组元素的类型不完全 
在包含自 helloworld.c:2 的文件中: 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:15:25: 错误:linux/cache.h:没有那个文件或目录 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:16:24: 错误:linux/kmod.h:没有那个文件或目录 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:18:29: 错误:linux/stringify.h:没有那个文件或目录 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:19:27: 错误:linux/kobject.h:没有那个文件或目录 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:20:31: 错误:linux/moduleparam.h:没有那个文件或目录 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:21:23: 错误:asm/local.h:没有那个文件或目录 
在包含自 /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:23 的文件中, 
                 从 helloworld.c:2: 
/usr/include/asm/module.h:4:2: 警告:#warning Using kernel headers in userspace! 
In file included from helloworld.c:2: 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:50: 错误:字段 ‘attr’ 的类型不完全 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:61: 错误:字段 ‘kobj’ 的类型不完全 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:573: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_register’ 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:575: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_unregister’ 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:576: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_get_request’ 
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:578: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_put’ 
哪位大虾帮我分析一下什么地方出了问题?  谢谢!! 
 
[ 本帖最后由 SeanYu 于 2007-9-18 20:44 编辑 ] |   
 
 
 
 |