a simple question about module programming
i am new man ,and i want to study module programming ,as a start i test following programming:
/*hello.c*/
#ifndef MODULE
#define MODULE
#endif
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/kernel.h>
#include <linux/module.h>
int init_module(void) {
printk("Hello World!\n");
return 0;
}
void cleanup_module(void) {
printk("Goodbye world!\n");
}
MODULE_LICENSE("GPL");
but when i compile it,it report me these messages:
# cc -O2 -Wall -c hello.c
In file included from /usr/include/linux/module.h:10,
from hello.c:8:
/usr/include/linux/config.h:5:2: error: #error Incorrectly using glibc headers for a kernel module
hello.c: 在函数 ‘init_module’ 中:
hello.c:11: 警告:隐式声明函数 ‘printk’
how to fix the error? (the last two lines is warnning)
any answer would be appreciated very much
|