15

I have a makefile project comprised of many source, header and other files, which I am trying to convert to an Eclipse "native" project. The problem that the Indexer reports errors and warning on files that exist in the directories but are excluded form the build. As a consequence, large parts of my directory tree are marked with the red x sign.

How can I make the Indexer to ignore specific file and/or directories?

Note: when defining a directory as "Derived" it is excluded form further searches, but unfortunately not from code analysis. Using project Resource Filters does not solve the problem either.

ysap
  • 7,723
  • 7
  • 59
  • 122

3 Answers3

16

Individual files are tricky however folders should be possible. Right click on the project -> Properties -> C/C++ General -> Paths and Symbols

Have a look at the 'Source Location' tab:

  • (a) completely remove a source folder or
  • (b) define an exlusion filter (where you can also add folders, filters and to a certain extent also files etc.)
  • (c) Highlight one or several files or folders by left clicking it. Then, right click one of the selected files, then chose Resource Configurations -> Exclude from build.... It will exclude all selected files or folders.
  • (d) Also take a look at File Types (in C/C++ General) and click through the other tabs of 'Paths and Symbols' and see if something can be removed...
  • (e) And as you may have seen there is also an Indexer (Right click on the project -> Properties -> Indexer which can be configured

Now I hope the DS-5 guys didn't deactivate all of those options...

Update: Of course those options are also available (at least some of those) in CDT. I changed my description accordingly...

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
Lonzak
  • 9,334
  • 5
  • 57
  • 88
  • Thanks. Unfortunately, I am using CDT, and more specifically, the ARM's DS-5 adaptation of it, so there are no Java settings, and specifically not the options you mentioned. – ysap Jul 10 '15 at 13:55
  • Thanks for the update. I believe that (a) -> (d) intend for exclusion from the build itself, which is not my intention. As for (e), see my answer to the question. Unless DS-5 removed some CDT options, I don't see how to exclude a file *only* from indexing using the Indexer settings tab. – ysap Jul 10 '15 at 14:53
  • In my specific case I have a source directoy which contains 3 asm files - `startup.s`, `startup_cm0.s` and `startup_cm4.s`. Of these files, only the `startup_cm4.s` is built into the project. The other two are thus excluded from the build, and via the Indexer settings, they are excluded from indexing. But the I cannot exclude the one required source, or I'll get a linker error. – ysap Jul 10 '15 at 14:56
  • Option (b) did not work but (c) did! (Eclipse 4.7.1., Eclipse CDT 9.3.2.201709131603 -- as used in ModusToolbox 1.1). – MrMas Dec 16 '19 at 21:29
15

Note - this is a partial answer

Like many features in Eclipse, this is yet another option buried inside the endless configuration dialogs, and has a default setting which is contrasting the common sense...

In order to exclude indexing of files that are excluded from the build, uncheck:

Window -> Preferences -> C/C++ -> Indexer -> Index source files not included in the build

I did not find yet a way of excluding files the are included in the build. Similarly, I could not find how to exclude whole directories, but if all sources in a directory are excluded from build, then with this setting unchecked, it will be excluded from indexing as well.

ysap
  • 7,723
  • 7
  • 59
  • 122
  • Answers the original question well I think. That unanswered question of "excluding files that *are* included in the build" remains of great interest though. I've opened a specific question: https://stackoverflow.com/questions/49310011/exclude-files-from-eclipse-indexing-that-are-included-in-the-build – Heath Raftery Mar 15 '18 at 22:07
1

Ignoring specific files/directories from indexing is possible by using a specific Indexer build configuration:

  1. Prepare a new (Indexer-specific) build configuration.
  2. Exclude unwanted source files from this configuration using the Source Location exclude filter.
  3. Let Indexer use this particular build configuration.

See step-by-step details here: https://stackoverflow.com/a/69469698/1744707

Jakub
  • 136
  • 1
  • 6