views:

3271

answers:

3

Eclipse CDT provides two indexers for C/C++ code (Preferences > C/C++ > Indexer). Does anybody know what the exact difference is between these two?

The help file isn't exactly enlightening:

"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."

What does it mean to be more accurate: does it index more things, and if so which ones?

+1  A: 

I believe it always reparses any found/included files without "caching". The reason if that the contents of the files might depend on the preprocessor definitions so it is always reparsed. Fast parser assumes nothing has changed since the file was first encountered.

(but I could be wrong)

Hrvoje Prgeša
A: 

Does anybody know what the exact difference is between these two?

In my experience, about 32MB heap.

greyfade
+3  A: 

Here is an excerpt from the CDT page describing their parsing and indexing(CDT/designs/Overview of Parsing). It gives a pretty good description of what the differences are and where the fast indexer can fail:

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.

CDT supports three different indexing modes, fast indexing, full indexing and no indexing. The default setting is 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 added to the index, while the full indexer will always write a copy of a header file to the index every time it is included.

The fast indexer is the preferred option; however it may not be fully accurate under certain circumstances. 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 places. The fast indexer will not be accurate in this scenario because it will only index the header the first time it is encountered. The full indexer will properly index the header for each time it is included.

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.

dagorym