Linux 内核错误:标记“(”之前缺少二元运算符

z0l*_*pka 3 c kernel-module linux-kernel c-preprocessor

Linux 内核模块中的一些简单预处理器代码会出现以下错误:

标记“(”之前缺少二元运算符

代码:

#if defined(AAA) || defined(BBB)

#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,13,0)
#define SOME 111
#else
#define SOME 222
#endif

#define OTHER 999

#else

#define SOME 1
#define OTHER 9

#endif /* AAA || BBB */
Run Code Online (Sandbox Code Playgroud)

那个帖子没有帮助。

bru*_*uno 6

该错误意味着 KERNEL_VERSION 未定义

你错过了#include <linux/version.h>


编辑

关于内核版本另请参阅:是否有宏定义来检查Linux内核版本?