How to correct the error "implicit declaration of function '
Posted: Fri Sep 27, 2013 12:32 am
Look:
When I compile the file __module_address.c,it always display
the error: "implicit declaration of function '__module_address'",
how to correct it?
Code: Select all
//the file:Makefile
ifneq ($(KERNELRELEASE),)
obj-m += __module_address.o
else
PWD := $(shell pwd)
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD)
clean:
rm -rf *.o *.mod.c *.ko *.symvers *.order *.markers *~
endif
//the file __module_address.c
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int __init __module_address_init(void);
static void __exit __module_address_exit(void);
int a_module(void)
{
return 0;
}
int __init __module_address_init(void)
{
struct module * ret ;
unsigned long addr = (unsigned long)a_module;
preempt_disable();
ret = __module_address(addr) ;
preempt_enable();
if( ret != NULL )
{
printk("<0>ret->name: %s\n",ret->name);
printk("<0>ret->state: %d\n",ret->state);
printk("<0>ret->core_size: %lu\n",ret->core_size);
printk("<0>refs of %s is %d\n",ret->name, module_refcount(ret));
}
else
{
printk("<0>__module_address return NULL !\n");
}
return 0;
}
void __exit __module_address_exit(void)
{
printk("<0>module exit ok!\n");
}
module_init(__module_address_init);
module_exit(__module_address_exit);
the error: "implicit declaration of function '__module_address'",
how to correct it?