本文主要是介绍驱动模块编译错误提示--implicit declaration of function ‘kmalloc’,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
从新编译以前的一个驱动测试模块
以前是在FC9,但是FC14出现如下编译错误,
make: Entering directory `/usr/src/kernels/2.6.35.6-45.fc14.i686'
CC [M] /home/ty/development/driver/ch6/globalmem.o
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_read’:
/home/ty/development/driver/ch6/globalmem.c:77:7: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_write’:
/home/ty/development/driver/ch6/globalmem.c:100:7: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_init’:
/home/ty/development/driver/ch6/globalmem.c:185:3: error: implicit declaration of function ‘kmalloc’
/home/ty/development/driver/ch6/globalmem.c:185:18: warning: assignment makes pointer from integer without a cast
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_exit’:
/home/ty/development/driver/ch6/globalmem.c:202:3: error: implicit declaration of function ‘kfree’
make[1]: *** [/home/ty/development/driver/ch6/globalmem.o] Error 1
make: *** [_module_/home/ty/development/driver/ch6] Error 2
make: Leaving directory `/usr/src/kernels/2.6.35.6-45.fc14.i686'
在网上找了一下,是缺少了一个头文件
#include <linux/slab.h>
加上之后就没问题了
驱动源代码
http://blog.csdn.net/tiany524/archive/2010/09/14/5884535.aspx
这篇关于驱动模块编译错误提示--implicit declaration of function ‘kmalloc’的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!