Eclipse CDT 索引无法在项目中查找声明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9077987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:38:34  来源:igfitidea点击:

Eclipse CDT indexing not working to find declarations within the project

eclipseindexingeclipse-cdtinclude-path

提问by iammilind

I have installed Eclipse & CDT plugin on newly installed Ubuntu. The indexing is set to "Fast indexing" which is recommended ("Full Indexing" seems to have marginal difference).

我已经在新安装的 Ubuntu 上安装了 Eclipse 和 CDT 插件。索引设置为推荐的“快速索引”(“完整索引”似乎有边际差异)。

At so many places, if I press 'F3'('show declaration') on any classname or include file name, the cursor remains stand still and it doesn't lead to the declaration. However, it works for standard files and symbols like, stdio.h, std::vectorand so on.

在很多地方,如果我'F3'在任何class名称或包含文件名上按('show declaration') ,光标将保持静止并且不会导致声明。但是,它适用于标准的文件和喜欢,符号stdio.hstd::vector等等。

For example, I have 2 files,

例如,我有 2 个文件,

/home/myself/Workspace/Project/X/Y/include/file.h
/home/myself/Workspace/Project/X/src/file.cpp

I am not able to see any declaration of any classor variables displayed in file.cppwhich are residing inside file.h. Even pressing 'F3'on #include"file.h", I am not able to go to file.h.

我无法看到任何任何声明class显示或变量file.cpp被里面居住file.h。即使按'F3'#include"file.h",我不能去file.h

Eclipse Workspace is created at Workspacefolder the C++ project is created at Projectfolder. To store the include path, I have followed this procedure in Eclipse:

Eclipse 工作区在Workspace文件夹中创建,C++ 项目在Project文件夹中创建。为了存储包含路径,我在 Eclipse 中遵循了以下过程:

Project -> Properties -> C/C++ General -> Paths and Symbols -> Library and Paths -> Add "/Project/X/Y/include/file.h"(used 'Workspace' and 'FileSystem' tabs both)

项目 -> 属性 -> C/C++ 常规 -> 路径和符号 -> 库和路径 -> 添加“/Project/X/Y/include/file.h”(使用了“工作区”和“文件系统”选项卡)

But still no luck. I have done enough searching on internet and SO, but couldn't find anything useful. Note that, I am using eclipse only for code browsing and not for building the code as of now.

但仍然没有运气。我已经在互联网和 SO 上进行了足够的搜索,但找不到任何有用的东西。请注意,我目前仅将 eclipse 用于代码浏览,而不是用于构建代码。

回答by iammilind

Ok, got it working. Actually whatever include pathsI have included in Paths and Symbolsare redundant and they make no difference as everything under Workspace/Projectwill be indexed.

好的,开始工作了。实际上,我包含的任何包含路径Paths and Symbols都是多余的,它们没有区别,因为下面的所有内容都Workspace/Project将被索引。

The solution is very weird and it's related to scalability, which I came to know from this link. In Eclipse go to,

解决方案非常奇怪,它与可扩展性有关,我是从这个链接了解到的。在 Eclipse 中转到,

Window -> Preferences -> C/C++ -> Editor -> Scalability -> "Enable scalability mode when ..."

窗口 -> 首选项 -> C/C++ -> 编辑器 -> 可扩展性 -> “启用可扩展性模式...”

Set a huge number such as 500000and press "OK". The problem was solved! For my case the actual set value was 5000and the source file I was seeing was of 16k+lines.

设置一个巨大的数字,例如,500000然后按“确定”。问题解决了!对于我的情况,实际设置值是5000,而我看到的源文件是16k+行。