Community
Participate
Working Groups
If you create .cpp or .h files in the target folder (I know why would you, still someone did) these are picked up by the indexer. As the target folders are "derived" I would have thought these would not be picked up by the indexer. Looking at possible duplicates I see this comment making the same observation. https://bugs.eclipse.org/bugs/show_bug.cgi?id=527173#c2 I assume derived code is not part of the "source code" and as such should not be picked up by the indexer. More importantly leaving out derived folders should improve indexer performance.
There is a performance (and probable correctness) gain in doing this. However, I don't think the correct flag is derived, but rather whether the file is in what CDT considers a source folder. Derived c and c++ files should be considered and indexed if they are source files, e.g. Lexer or parser output files. I think the issue in Bug 527173 comment 2 is about core build and therefore how core build identifies what is a source folder and not. IIUC the MBS is what today identifies what are source folders. In comment 0, which build system are you referring to?
In my case the prebuild command of MBS copied a .cpp file in ${projDir}/${config}/sketch. Which I think is a really bad idea, but as usual not everybody agrees with me (more details in https://github.com/Sloeber/arduino-eclipse-plugin/issues/1143). The indexer picked up the cpp file, and this resulted in a unresolved include which triggered Sloeber to add a library (read triggered Sloeber to resolve the unresolved include). All this is good and desired behaviour but I had not expected the indexer to pick up the cpp file so it was also "unexpected" behaviour to me. I fully understand there are pro's and con's to parsing derived files. I personally would exclude them, but I'm biased because I don't use cpp file generating tools like lexer. If I really want to exclude ${projDir}/${config} from the indexer I can simply exclude it from build. Looks a bit weird but this way I proved the indexer -by default- indexes derived resources. I don't know how CDT distinguishes between source files and not source files. I thought that was based on the file extension and tags like derived and exclude from build.
I agree - the indexer and the MBS should "agree". If builder does not consider files in ${projDir}/${config}/sketch as part of the project, neither should the indexer. I just don't agree that derived should be the universal flag for that. Of course in a sketch project it can be though.