强制 Eclipse CDT 解析 #included 文件以突出显示
解析 C 源代码时,Eclipse 似乎忽略了定义宏的#includes。当涉及到突出显示以及有时自动完成时,这很糟糕。作为示例,假设有以下两个头文件:
bar.h:
#define BAZ 1
foo.h:
#include "bar.h" //<-- Jumping from here leads to the correct file
#ifdef BAZ
int baz() { //
return BAZ; // this section will be grayed out
} //
#else
int baz() {
return 42;
}
#endif
int foo() {
return baz(); // jumping from here will go to the second(42) function
}
到目前为止,我已尝试更改项目的发现选项/配置文件,并为索引器切换到“使用活动构建配置”一般偏好。 该项目是一个相对较小(但充满了宏)的 C/C++ 项目,使用外部构建器(autotools/make)。
附加说明:
我发现问题的一部分是我引用了来自不同项目的头文件,这些文件是使用 Makefile 安装到单独的目录中的。我将包含目录从已安装的目录切换到项目内部 /include 目录。现在,当我构建另一个项目时,它似乎解析了这些头文件中的宏。这并不完全漂亮,但对我来说有点用。
When parsing C sources, Eclipse seems to ignore #includes with respect to defined macros. This is bad when it comes to highlighting and also sometimes auto completion. As an example, assume the following two header files:
bar.h:
#define BAZ 1
foo.h:
#include "bar.h" //<-- Jumping from here leads to the correct file
#ifdef BAZ
int baz() { //
return BAZ; // this section will be grayed out
} //
#else
int baz() {
return 42;
}
#endif
int foo() {
return baz(); // jumping from here will go to the second(42) function
}
So far I have tried to change the Discovery options/profile for the project as well as switching to "Use active build configuration" for the indexer in the general preferences.
The project is a relatively small (yet riddled with macros) C/C++ project using an external builder (autotools/make).
Additional Notes:
I figured out that part of the problem is that I was referencing header files from a different project that were installed to a separate directory using Makefiles. I switched the include directory from the installed, to the project internal /include directory. Now when I build the other project, it seems to resolve the macros in those header files. This is not exactly pretty, but it kind of works for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
验证您已签入所有相关选项:
Verify you have all relevant options checked in: