error: void value not ignored as it ought to be
来源:互联网 发布:uplay邮箱域名 编辑:程序博客网 时间:2024/06/05 17:54
在编译字符设备驱动文件时出现了一个 error: void value not ignored as it ought to be 错误。 本人表示非常恼火。问题出在:
int ret = unregister_chrdev(Major,DEVICE_NAME);
编译器检测到在<linux/fs.h>文件中,unregister_chrdev函数没有返回值。
而我在搜了一下<linux/fs.h>头文件。在http://students.mimuw.edu.pl/SO/Linux/Kod/include/linux/fs.h.html 或者 http://lxr.linux.no/linux-bk+v2.6.10/include/linux/fs.h 中有:
extern int unregister_chrdev(unsigned int major, const char * name);
明明是有返回值的。但是这里编译器又为什么报错呢?
解决办法一:
ret = unregister_chrdev(MAJOR, DEVICE_NAME);
当注销此行时可以编译通过,找到linux/fs.h头文件,里面定义了unregister_chrdev()函数:
extern void unregister_chrdev(unsigned int,const char *);
此处定义的为void类型函数,而在程序中将其赋值给了ret,这就造成了编译错误。
于是注释了相应的代码,用unregister_chrdev(MAJOR, DEVICE_NAME);代替即可。这样就能通过编译了。
http://www.linuxidc.com/Linux/2010-02/24622.htm
在一个国外的网站上查到了,和上面的解决方法一样:
Code:
int ret = unregister_chrdev ( Major, DEVICE_NAME ); if( ret < 0 ) printk("Error in unregister_chardev : %d \n",ret);
Code:
unregister_chrdev ( Major, DEVICE_NAME );
网址:http://ubuntuforums.org/showthread.php?t=1845120
- error: void value not ignored as it ought to be
- error: void value not ignored as it ought to be .
- error: void value not ignored as it ought to be
- error: void value not ignored as it ought to be
- void value not ignored as it ought to be
- void value not ignored as it ought to be
- void value not ignored as it ought to be
- void value not ignored as it ought to be
- void value not ignored as it ought to be
- 解决:void value not ignored as it ought to be
- void value not ignored as it ought to be
- 编译内核模块 error: void value not ignored as it ought to be
- Android之error: void value not ignored as it ought to be(In function 'callMethod2')解决办法
- glog函数调用出现c++:void value not ignored as it ought to be错误
- Cache Reheating - Not to be Ignored
- 30.In which situation may the UNDO_RETENTION parameter be ignored, even if it is set to a value?
- ERROR: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be
- 使用 HTML5 开发离线应用
- SQL递归查询
- s12xe的小问题
- ddraw rgb显示
- ajax练习用json返回数据
- error: void value not ignored as it ought to be
- ARP的介绍
- 修改后的cxgrid样式
- tomcat outofmemoryerror
- 图像处理滤波器(六)——频率滤波器(Frequency Filter)
- 获取客户端IP的SQL存储过程
- Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask等
- 八款开源 Android 游戏引擎 (巨好的资源)
- java.util.concurrent我的理解