linux全局变量current,内核模块,使用全局变量current, 包含#include

请大家帮忙:

#include

只要包含这个头就出现错误:

[root@localhost test_module]# make

gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -I/usr/include/ -c hello.c

In file included from /usr/include/linux/fs.h:23,

from /usr/include/linux/capability.h:17,

from /usr/include/linux/binfmts.h:5,

from /usr/include/linux/sched.h:9,

from hello.c:16:

/usr/include/linux/string.h:8:2: warning: #warning Using kernel header in userland!

In file included from /usr/include/linux/sched.h:14,

from hello.c:16:

/usr/include/linux/timex.h:173: field `time' has incomplete type

In file included from /usr/include/linux/bitops.h:69,

from /usr/include/asm/system.h:7,

from /usr/include/linux/sched.h:16,

from hello.c:16:

/usr/include/asm/bitops.h:327:2: warning: #warning This includefile is not available on all architectures.

/usr/include/asm/bitops.h:328:2: warning: #warning Using kernel headers in userspace: atomicity not guaranteed

In file included from /usr/include/linux/signal.h:4,

from /usr/include/linux/sched.h:25,

from hello.c:16:

/usr/include/asm/signal.h:107: parse error before "sigset_t"

/usr/include/asm/signal.h:110: parse error before '}' token

In file included from /usr/include/linux/sched.h:81,

from hello.c:16:

/usr/include/linux/timer.h:45: parse error before "spinlock_t"

/usr/include/linux/timer.h:53: parse error before '}' token

/usr/include/linux/timer.h:67: parse error before "tvec_base_t"

/usr/include/linux/timer.h:101: parse error before "tvec_bases"

/usr/include/linux/timer.h: In function `init_timer':

/usr/include/linux/timer.h:105: dereferencing pointer to incomplete type

/usr/include/linux/timer.h:105: dereferencing pointer to incomplete type

/usr/include/linux/timer.h:106: dereferencing pointer to incomplete type

/usr/include/linux/timer.h: In function `timer_pending':

/usr/include/linux/timer.h:121: dereferencing pointer to incomplete type

hello.c: In function `init_module':

hello.c:22: warning: implicit declaration of function `printk'

hello.c:37:2: warning: no newline at end of file

make: *** [hello.o] Error 1

怎么回事,谢谢!

|

加入kernel的include路径,-I/usr/src/linux-2.4/include

另外就是系统自带的kernel source最好配置好后make dep

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值