|
/* hello.c */
/* The necessary header files */
/* Standard in kernel modules */
#include <linux/kernel.h>; /* We're doing kernel work */
#include <linux/module.h>; /* Specifically, a module */
/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
/* If we return a non zero value, it means that init_module failed and
* the kernel module can't be loaded */
return 0;
}
/* Cleanup - undid whatever init_module did */
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}
[/code]
[root@RedHat zhangzhm]# gcc -O6 -Wall -DCONFIG_KERNELD -DMODULE -D__KERNEL__ -DL
hello.c: In function `init_module':
hello.c:9: warning: implicit declaration of function `printf'
hello.c: In function `cleanup_module':
hello.c:17: warning: implicit declaration of function `printk'
编译无法通过。为什么? |
|