编译自定义OpenWRT时遇missing binary operator编译错误求助
OpenWRT编译错误排查与修复
问题原因
编译错误出现在#elif分支,核心问题是预处理器处理SIGSTKSZ < 16384时,SIGSTKSZ可能未被定义。当系统头文件中没有定义SIGSTKSZ时,预处理器会将未定义的宏替换为空,导致代码逻辑变成HAVE_LIBSIGSEGV && < 16384,触发语法错误。
修复方案
需要在#elif条件中先检查SIGSTKSZ是否已定义,再进行数值比较。修改后的代码如下:
#include <signal.h> #if ! HAVE_STACK_T && ! defined stack_t typedef struct sigaltstack stack_t; #endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #elif HAVE_LIBSIGSEGV && defined(SIGSTKSZ) && SIGSTKSZ < 16384 /* libsigsegv 2.6 through 2.8 have a bug where some architectures use more than the Linux default of an 8k alternate stack when deciding if a fault was caused by stack overflow. */ # undef SIGSTKSZ # define SIGSTKSZ 16384 #endif
验证逻辑
- 若系统头文件未定义
SIGSTKSZ,直接走#ifndef分支将其定义为16384 - 若系统头文件已定义
SIGSTKSZ,且HAVE_LIBSIGSEGV为真、SIGSTKSZ小于16384时,重新定义为16384 - 其他情况保留系统头文件的
SIGSTKSZ定义
内容的提问来源于stack exchange,提问作者Kuro
相关产品推荐
相关产品推荐

