Linux驱动——fatal error: asm/system.h: No such file or directory 如何解决
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
写字符设备驱动程序时,出现错误: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




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 年前
更多推荐
所有评论(0)