- 论坛徽章:
- 0
|
以下是小弟写的一个内核模块,编译时出错,错误行为:
printk(KERN_ALERT"pa->_count: %lx", page_to_pfn(pa));//atomic_read(pa->_count)); //(pa - mem_map)/sizeof(struct page));
提示说:
/home/Royale/module_pro/mem_map_test.c:13: 错误:在指向不完全类型的指针上执行算术运算
/home/Royale/module_pro/mem_map_test.c:13: 错误:在指向不完全类型的指针上执行算术运算
代码为:
#include<linux/kernel.h>
#include<linux/module.h>
#include<asm/uaccess.h>
#include<linux/init.h>
#include<asm-generic/memory_model.h>
extern struct page * mem_map;
static struct page * pa;
int __init init_module(void)
{
pa = alloc_page(__GFP_HIGH);
printk(KERN_ALERT"pa->_count: %lx", page_to_pfn(pa));//atomic_read(pa->_count)); //(pa - mem_map)/sizeof(struct page));
return 0;
}
void __exit cleanup_module(void)
{
__free_page(pa);
}
这是怎么回事啊?我把page_to_pfn(pa)换成atomic_read(pa->_count)就会提示:
/home/Royale/module_pro/mem_map_test.c:13: 错误:提领指向不完全类型的指针
这是什么错误,怎么解决啊? |
|