我现在写了一个在简单不过的驱动 #ifndef MODULE #define MODULE #endif
#include <linux/config.h> #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/malloc.h> #include <linux/types.h>
#include <linux/fs.h>
//#include <linux/errno.h> //#include <linux/types.h> static int init_module(void) { printk("<1>Hello,world!\n"); return 0; } static void cleanup_module(void) { printk("<1>Goodbye\n"); } #ifndef MODULE #define MODULE #endif
#include <linux/config.h> #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/malloc.h> #include <linux/types.h>
#include <linux/fs.h>
//#include <linux/errno.h> //#include <linux/types.h> static int init_module(void) { printk("<1>Hello,world!\n"); return 0; } static void cleanup_module(void) { printk("<1>Goodbye\n"); } #ifndef MODULE #define MODULE #endif
#include <linux/config.h> #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/malloc.h> #include <linux/types.h>
#include <linux/fs.h>
//#include <linux/errno.h> //#include <linux/types.h> static int init_module(void) { printk("<1>Hello,world!\n"); return 0; } static void cleanup_module(void) { printk("<1>Goodbye\n"); } #ifndef MODULE #define MODULE #endif
#include <linux/config.h> #include <linux/module.h>
#include <linux/kernel.h>
#include <linux/malloc.h> #include <linux/types.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/types.h>
static int init_module(void) { printk("<1>Hello,world!\n"); return 0; } static void cleanup_module(void) { printk("<1>Goodbye\n"); } module_init(init_module); module_exit(cleanup_module); 但是发现我不能引用linux/fs.h 报错信息如下: [root@localhost ARM2CPLD]# make arm-linux-gcc -c -O2 -Wall -DMODULE -I/ARMs3c2410/kernel/include ARM2CPLD.c In file included from ARM2CPLD.c:15: /ARMs3c2410/kernel/include/linux/malloc.h:4:2: warning: #warning linux/malloc.h is deprecated, use linux/slab.h instead. In file included from /ARMs3c2410/kernel/include/linux/fs.h:13, from ARM2CPLD.c:16: /ARMs3c2410/kernel/include/linux/types.h:14: error: parse error before "dev_t" /ARMs3c2410/kernel/include/linux/types.h:14: warning: type defaults to `int' in declaration of `dev_t' /ARMs3c2410/kernel/include/linux/types.h:14: warning: data definition has no type or storage class ARM2CPLD.c: In function `init_module': ARM2CPLD.c:22: warning: implicit declaration of function `printk' ARM2CPLD.c: At top level: ARM2CPLD.c:29: warning: type defaults to `int' in declaration of `module_init' ARM2CPLD.c:29: warning: parameter names (without types) in function declaration ARM2CPLD.c:29: warning: data definition has no type or storage class ARM2CPLD.c:30: warning: type defaults to `int' in declaration of `module_exit' ARM2CPLD.c:30: warning: parameter names (without types) in function declaration ARM2CPLD.c:30: warning: data definition has no type or storage class ARM2CPLD.c:21: warning: 'init_module' defined but not used ARM2CPLD.c:26: warning: 'cleanup_module' defined but not used 我看了一下,好像主要的错误就是那个 /ARMs3c2410/kernel/include/linux/types.h:14: error: parse error before "dev_t" 请问我这个东西是怎么一回事啊,谢谢 |