当前位置: 技术问答>linux和unix
内核模块编译问题(菜鸟级问题)
来源: 互联网 发布时间:2015-01-04
本文导语: 系统环境:redhat linux7.3(kernel 2.4.18-3) 程序:hello.c #include #include #if CONFIG_MODVERSIONS == 1 #define MODVERSIONS #include #endif int init_module() { printk("......................"); return; } void cleanup_module() { printk("-...
系统环境:redhat linux7.3(kernel 2.4.18-3)
程序:hello.c
#include
#include
#if CONFIG_MODVERSIONS == 1
#define MODVERSIONS
#include
#endif
int init_module()
{
printk("......................");
return;
}
void cleanup_module()
{
printk("---------------------");
}
Makefile文件:
CC=gcc
MODCFLAGS:=-Wall -DMODULE -D_KERNEL_ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
错误提示:
in file included from hello.c:2:
/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 "}"
......
请教这是什么原因?
程序:hello.c
#include
#include
#if CONFIG_MODVERSIONS == 1
#define MODVERSIONS
#include
#endif
int init_module()
{
printk("......................");
return;
}
void cleanup_module()
{
printk("---------------------");
}
Makefile文件:
CC=gcc
MODCFLAGS:=-Wall -DMODULE -D_KERNEL_ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
错误提示:
in file included from hello.c:2:
/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 "}"
......
请教这是什么原因?
|
我也碰到过这个问题,一定要包含,而且要放在最前面!
|
问题出在别的地方.
|
把
#if CONFIG_MODVERSIONS == 1
#define MODVERSIONS
#include
#endif
删除
好像2.4以后的内河不再使用这样的格式
#if CONFIG_MODVERSIONS == 1
#define MODVERSIONS
#include
#endif
删除
好像2.4以后的内河不再使用这样的格式