我有一个包含 C++ 和 C 文件的项目。代码编译并正确运行,但我需要摆脱以下错误:
符号“ERANGE”无法解析
我能够使用这两个文件(Ubuntu 上最新的 x64 Elipse Juno)重现它:
主.h:
#ifndef MAIN_H_
#define MAIN_H_
extern "C" {
#include <errno.h>
}
#endif /* MAIN_H_ */
主.cpp:
#include <cerrno>
#include <cassert>
#include "main.h"
int main(int argc, char * argv[]) {
assert(errno != ERANGE); // <-- CDT ERROR here
return 0; }
在 ERANGE 上正确执行Open Declaration会将我带到 /usr/include/asm-generic/errno-base.h 文件。
以下针对类似问题的解决方法无效:
- 设置索引器 -> 使用活动构建配置
- 手动将 ERANGE 符号添加到项目路径和符号
- 将 main.cpp 添加到Preferences -> C/C++ -> Code Analysis -> Symbol is not resolved -> Customize Selected... -> Scope -> Exclusion patterns
唯一可行的解决方案是禁用符号未完全解决错误,但这会导致我错过真正的问题。
编辑: CDT 错误提交https://bugs.eclipse.org/bugs/show_bug.cgi?id=404017