写字符设备驱动程序时,出现错误:fatal error: asm/system.h: No such file or directory

错误信息可知,缺少此头文件

原因:

        Linux内核是不断地更新换代,即3.3版本之后内核用switch_to.h替换了曾经的system.h头文件。

解决方法:

        可在终端输入uname -r,查看自己Linux内核版本。如,我的内核版本是4.2.0-27-generic,可知为3.3之后版本,直接使用#include <asm/switch_to.h>替换掉原来的#include <asm/system.h>

        或者写以下下代码即可:

#include <linux/version.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 3, 0)
        #include <asm/switch_to.h>
#else
        #include <asm/system.h>
#endif

        

GitHub 加速计划 / li / linux-dash
10
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:8 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐