error: void value not ignored as it ought to be
来源:互联网 发布:河南省软件协会 编辑:程序博客网 时间:2024/05/22 08:06
在编译字符设备驱动文件时出现了一个 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
- IE6.0 不支持LI:HOVER的解决方法
- Poj 2359 Questions (约瑟夫环)
- ajax读取本地xml文件要注意的地方
- 【Android面试】Android面试题集锦
- DirectSound应用,播放wav文件
- error: void value not ignored as it ought to be
- 从五个方面下手,彻底解决客户需求难题
- LeetCode Binary Tree Preorder Traversal
- LCD参数
- 分享腾讯微博C#版本SDK
- java读取xml文件并分页显示
- redis命令中文参考
- android 的listview的优化
- unity制作出的apk识别不出3D模型