求助:为什么加了<linux/sched.h>之后会有错误啊?有-I /usr/src/linux-2.4.20-8/include
我才学驱动程序,写的一个hello world
不加 <linux/sched.h> 时正常,加了之后报错
#define MODULE
#include <linux/module.h>
#include <linux/sched.h>
int xiayu;
int init_module(void)
{
int err;
MODULE_LICENSE( "GPL ");
printk( " <1> hello,world\n ");
return 0;
}
void cleanup_module(void)
{
printk( " <1> Goodbye cruel world\n ");
}
gcc -c -I /usr/src/linux-2.4.20-8/include /home/xy/root/hello.c
我在网上查了,说要加 -I /usr/src/linux-2.4.20-8/include
我加了后,只是错误提示变了,但是还是报错,请各位帮帮忙.帮我看看是怎么回事?谢谢了!
In file included from /usr/src/linux-2.4.20-8/include/linux/sched.h:16,
from /home/xy/root/hello.c:4:
/usr/src/linux-2.4.20-8/include/linux/timex.h:173: field `time ' has incomplete type
In file included from /usr/src/linux-2.4.20-8/include/linux/sched.h:23,
from /home/xy/root/hello.c:4:
/usr/src/linux-2.4.20-8/include/asm/mmu.h:12: field `sem ' has incomplete type
In file included from /usr/src/linux-2.4.20-8/include/linux/sched.h:31,
from /home/xy/root/hello.c:4:
/usr/src/linux-2.4.20-8/include/linux/pid.h:18: field `task_list ' has incomplete type
/usr/src/linux-2.4.20-8/include/linux/pid.h:19: field `hash_chain ' has incomplete type
/usr/src/linux-2.4.20-8/include/linux/pid.h:24: field `pid_chain ' has incomplete type
/usr/src/linux-2.4.20-8/include/linux/pid.h:36: parse error before '( ' token
/usr/src/linux-2.4.20-8/include/linux/pid.h:38: parse error before '( ' token
/usr/src/linux-2.4.20-8/include/linux/pid.h:43: parse error before '( ' token
/usr/src/linux-2.4.20-8/include/linux/pid.h:49: parse error before '( ' token
/usr/src/linux-2.4.20-8/include/linux/pid.h:52: parse error before '( ' token
------解决方案--------------------哦,你是2.4内核,那看Linux Device Driver 2nd,或许你已经在看了,建议看看它的示例代码,还有Makefile的写法。