2

I would like to index every #ifdef and #else blocks in my C/C++ source files with my CDT indexer 8.0.2 on Eclipse indigo on Ubuntu.

Adding symbols wouldn't work since it would not cover #else blocks

Is there any way that I can force Eclipse CDT to simply ignore the #ifdef and #else blocks? like other indexers do ( like emacs cscope )

I've been searching for days and didn't find any good solution.

I have a really big amount of code and would better not edit it to remove #ifdefs even temporary.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
John Snow
  • 21
  • 4
  • Possible duplicate of [How can I get Eclipse to index code inside #ifdef .... #endif](http://stackoverflow.com/questions/3121920/how-can-i-get-eclipse-to-index-code-inside-ifdef-endif) – Ciro Santilli OurBigBook.com Apr 02 '17 at 13:15

1 Answers1

0

The short answer is no. The CDT pre-processor doesn't work that way. It follows the correct semantics, meaning it only parses one branch of a #ifdef. Emacs may be going into each branch but its not doing an analysis that's as correct or complete as CDT.

Your only option is to set up multiple build configurations that are configured to parse each branch. Then you can switch build configurations when you want to work in the different branches. This is far from ideal though because it can be time consuming to set up and it will trigger a re-index every time you switch. (Also you have to configure it to do the re-index, go to Window > Preferences > C/C++ > Indexer and select "Use active build configuration")

Note that the CDT parser will parse inside of inactive #else branches just to find declarations to show in the outline view.

Mike Kucera
  • 2,003
  • 1
  • 14
  • 18