找回密码
 注册
查看: 1574|回复: 0

编译hello module,出现 warning

[复制链接]
发表于 2005-8-8 11:21:32 | 显示全部楼层 |阅读模式
程序如下:

   
#define __NO_VERSION__                                                                                                                                                                  
#include <linux/kernel.h>      
#include <linux/module.h>                                                                                                                                                   
#include <linux/init.h>           



           /* Deal with CONFIG_MODVERSIONS */



#if CONFIG_MODVERSIONS==1


#define MODVERSIONS


#include <linux/modversions.h>


#endif

MODULE_LICENSE("GPL");
                                                                                                                                                                              
     // This function is called when driver is installed by insmod                                                                                                                                 
     int init_module(void)                                                                                                                                                                        
     {                                                                                                                                                                                             
             printk("<1>init_module:  Hello World!\n");                                                                                                                                               
             return 0;   // return 0 means success; any other value means failure                                                                                                                  
     }                                                                                                                                                                                             
                                                                                                                                                                                                   
     // This function is called when driver is uninstalled by rmmod                                                                                                                                
     void cleanup_module(void)                                                                                                                                                                     
     {                                                                                                                                                                                             
             printk("<1>cleanup_module:  Hello World cleaning up....\n");                                                                                                                             
     }            


编译出现警告:
love.c: In function `init_module':
love.c:30: warning: implicit declaration of function `printk'

使用insmod可以加载,没有警告,不过也没有打印输出!
使用rmmod,提示rmmod: module love.o is not loaded,比较奇怪,明明lsmod 里有的
使用 modprobe -r love.o可以卸载掉

如何消除那个警告呢?
为什么在终端里没有输出呢?
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-15 06:03 , Processed in 0.024084 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表