内存分配模块编译出错
2012-11-27 22:30
267 查看
编译模块时,出现以下问题
/home/alloc_mem.c:13: warning: function declaration isn't a prototype
/home/alloc_mem.c: In function 'alloc_init':
/home/alloc_mem.c:14: error: implicit declaration of function'kmalloc'
/home/alloc_mem.c:14: warning: assignment makes pointer from integer without a cast
/home/alloc_mem.c:19: warning: assignment makes pointer from integer without a cast
/home/alloc_mem.c: At top level:
/home/alloc_mem.c:25: warning: function declaration isn't a prototype
/home/alloc_mem.c: In function 'alloc_exit':
/home/alloc_mem.c:26: error: implicit declaration of function 'kfree'
/home/alloc_mem.c:27: warning: passing argument 1 of 'free_pages' makes integer from pointer without a cast
make[2]: *** [/home/shiyan/4-4-1/neicun/alloc_mem.o] Error 1
make[1]: *** [_module_/home/shiyan/4-4-1/neicun] Error 2
make[1]: Leaving directory `/home/shiyan/neihe/linux-2.6.36.2-v1.05'
make: *** [all] Error 2
在网上找了一下,是缺少了一个头文件#include <linux/slab.h>加上之后就没问题了,另外还有驱动的加载函数还有卸载函数也要在括号中注意加上void,避免一些不必要的错误
1.在编译内核时 出现drivers/char/memdev.c:174: error: implicit declaration of function'kmalloc'
在网上找了下原来是少了头文件#include<linux/slab.h>。
2.app-mem.c:9: warning: incompatible implicit declaration of built-in function 'strcpy'
原因是缺少头文件#include<string.h>。
/home/shiyan/5-1-1CQD/ioctlqudong/memdev.c:84: error: unknown field 'ioctl'specified in initializer
在linux-2.6.36内核上加载编译驱动时,出现
error:unknown field 'ioctl' specified in initializer
原因是:在2.6.36内核上file_operations发生了重大的改变:
原先的
int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);
被改为了
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
因而在实际驱动中,我们需要将原先的写的ioctl函数头给改成下面的unlocked_ioctl,在file_operations结构体的填充中也是一样。
/home/alloc_mem.c:13: warning: function declaration isn't a prototype
/home/alloc_mem.c: In function 'alloc_init':
/home/alloc_mem.c:14: error: implicit declaration of function'kmalloc'
/home/alloc_mem.c:14: warning: assignment makes pointer from integer without a cast
/home/alloc_mem.c:19: warning: assignment makes pointer from integer without a cast
/home/alloc_mem.c: At top level:
/home/alloc_mem.c:25: warning: function declaration isn't a prototype
/home/alloc_mem.c: In function 'alloc_exit':
/home/alloc_mem.c:26: error: implicit declaration of function 'kfree'
/home/alloc_mem.c:27: warning: passing argument 1 of 'free_pages' makes integer from pointer without a cast
make[2]: *** [/home/shiyan/4-4-1/neicun/alloc_mem.o] Error 1
make[1]: *** [_module_/home/shiyan/4-4-1/neicun] Error 2
make[1]: Leaving directory `/home/shiyan/neihe/linux-2.6.36.2-v1.05'
make: *** [all] Error 2
在网上找了一下,是缺少了一个头文件#include <linux/slab.h>加上之后就没问题了,另外还有驱动的加载函数还有卸载函数也要在括号中注意加上void,避免一些不必要的错误
1.在编译内核时 出现drivers/char/memdev.c:174: error: implicit declaration of function'kmalloc'
在网上找了下原来是少了头文件#include<linux/slab.h>。
2.app-mem.c:9: warning: incompatible implicit declaration of built-in function 'strcpy'
原因是缺少头文件#include<string.h>。
/home/shiyan/5-1-1CQD/ioctlqudong/memdev.c:84: error: unknown field 'ioctl'specified in initializer
在linux-2.6.36内核上加载编译驱动时,出现
error:unknown field 'ioctl' specified in initializer
原因是:在2.6.36内核上file_operations发生了重大的改变:
原先的
int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);
被改为了
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
因而在实际驱动中,我们需要将原先的写的ioctl函数头给改成下面的unlocked_ioctl,在file_operations结构体的填充中也是一样。
相关文章推荐
- 在不同模块分配和释放内存时出错的原因
- 在不同模块分配和释放内存时出错的原因
- 关于书上说的“编译的时候分配内存”
- 晓说智能指针shared_ptr为何可以实现跨模块分配和释放内存
- [经验之谈]C/C++的一个内存分配记录模块
- Android5.0 Gallery2上编译Gallery模块出错
- 内存分配的的模块已经基本写完。帮忙测试一下内存分配器。
- 简述C、C++程序编译的内存分配情况
- 转-关于书上说的“编译的时候分配内存”
- 设置和编译信息解析 程序运行耗时 内存分配MAP
- OO中的继承分析,主要分析在编译和运行过程中子类父类的方法、字段和实例化时候在内存中分配和执行的先后,以及两个原则
- 在一个模块中分配的内存在另外一个模块释放(转)
- ActivePerl5.8.8 build 819编译CPAN模块时出错的解决方法
- C/C++程序编译时和运行时内存区域分配
- 关于VS编译的程序内存分配只能用1.5~2G上限的优化方案
- 512M内存编译php出错
- php 模块编译提示libtool出错
- 1.22关于new动作的分析(编译时加载类信息,运行时分配内存)
- 编译到执行 关于内存分配
- 程序的内存分配即一个由C/C++编译的程序占用的内存分为以下几个部分