c++ - Eclipse 有两个 C/C++ 索引器(快速且完整): what's the difference?

标签 c++ c eclipse eclipse-cdt indexer

Eclipse CDT 为 C/C++ 代码提供了两个索引器(Preferences > C/C++ > Indexer)。有人知道这两者之间的确切区别是什么吗?

帮助文件并不完全有启发性:

"CDT supports the contribution of additional indexers, with 2 indexers being provided with the default CDT release:

  • Fast C/C++ Indexer : provides fastest indexing capabilities - both declarations and cross reference information. This is the recommended indexer.

  • Full C/C++ Indexer : provides even more accurate indexing capabilities at the cost of performance - both declarations and cross reference information."

更准确意味着什么:它是否索引更多的东西,如果是的话,是哪些?

最佳答案

这是 CDT 页面的摘录,描述了它们的解析和索引 (CDT/designs/Overview of Parsing)。它很好地描述了差异是什么以及快速索引器可能失败的地方:

Parsing and binding resolution is a slow process, this is a problem because the user expects code editing features such as content assist to be fast. For this reason CDT stores binding information in an on-disk cache called “the index” or “the PDOM” (Persisted Document Object Model) in order to be able to provide features that respond quickly to user requests.

Building the index involves parsing all the code in a project, resolving all the bindings and writing those bindings to the index. The index is then incrementally updated every time the user edits a file.

Older versions of CDT support three different indexing modes, fast indexing, full indexing and no indexing. The default setting being the fast indexer because indexing a large project can be a time consuming process. The difference between the fast and full indexers is that the fast indexer will skip header files that have already been parsed once, while the full indexer will always re-parse a header file every time it is included. However it is important to understand that the full indexer, despite its name, is still not fully accurate.

When a header file is included in a source file it is subject to any macros that have been defined at that point. Some library headers use macros in conjunction with preprocessor conditionals (#ifdefs) to partially include a header file. Sometimes such a header file is included more than once in a project, if the macros that the header depends on are different each time the header is included then different parts of the header may be included in different source files. Neither indexer will be accurate in this scenario because it will only index the header the first time it is encountered.

The Full indexer will re-parse headers it has already encountered, but it will not re-index them. Therefore source files that include a header may be parsed more accurately, but the header itself will only be indexed the one time. The full indexer is much slower than the fast indexer because of the extra parsing it does, but it is only marginally more accurate. For this reason the Full indexer is not recommended and has been removed from the current version of CDT.

Each project has a single PDOM associated with it. The PDOM is stored on disk as a flat binary file. The indexer will only index headers that are included by source files, so if there is a .h file in the project that is not being included by any .c or .cpp file, then normally it won’t get indexed. However there is a preference setting for indexing all files in the project.

关于c++ - Eclipse 有两个 C/C++ 索引器(快速且完整): what's the difference?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/763837/

相关文章:

c++ - std::array 和 boost::array 之间的差异

c++ - 函数模板中的参数推导

c - 边界检查字符串指针以获取 C 函数中的返回值

c - require 'serialport' 需要错误的 gem

c - 使用不同颜色的三角形镶嵌球体

java - jMockit 初始化错误 : java. lang.IllegalStateException:在 JDK 9 上运行

c++ - 我可以制作一个所有类都可以使用的模板 operator<< 重载吗? C++

c++ - 使用 WinAPI 创建菜单条

java - Ctrl+Shift+F 格式在 JSP 页面中不起作用

java - 运行我的新代码运行我的旧代码?