Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Indexer and "grey-background" problems with defines in c-sources and #ifdef in includes


At work I've noticed two problems with the indexer. I've posted these
without a satisfying answer in the cdt newsgroup a few days ago. Thus
I'll try it hopefully a little bit clearer here. Let's start with a
snippet to show these.

There are two include files and two C-sources with the following

#ifdef SOURCE_X
  #include "Step2.h"
  int variable1 = 0;
  extern int variable1;

#ifdef SOURCE_X
  int variable2 = 0;
  extern int variable2;

#define SOURCE_X
#include "Step1.h"
void doSomething(void)
  variable1 = 4;
  variable2 = 3;

#include "Step1.h"
void doSpecial(void)
  variable1 = 4;
In Main.c SOURCE_X is defined for the definitions of the global
variables in the two include files. In AddOn.c SOURCE_X is not defined.
Step1.h includes Step2.h dependent on SOURCE_X is defined. 
Problem #1, possible a bug:
If the indexer starts with Main.c on both variables code proposal and
open declaration with F3 works fine, but the line 2 of Step2.h is greyed
(background) in the editor. I.e. the indexer has parsed line 2 of
Step2.h but the editor doesn't show this. 

Is it a bug? 

Problem #2:
If the indexer starts with AddOn.c, SOURCE_X is not defined and the
variable2 is unknown. For this variable code completion is not possible
and the declaration can't be opened with the key F3. The command open
declaration (F3) on variable1 jumps to line 5 in Step1.h. I.e. the
indexer has parsed both includes with undefined SOURCE_X. That's not
desired. What options have I to force the parsing of the include files
with SOURCE_X defined? Adding Main.c to the indexer preference "index
up-front" helps, but is not suitable for large projects with multiple
crosswise includes in different C-sources. The "SOURCE_X" defines have
to be in the C-sources, thus adding these defines to the compile options
of the C-sources is not desired. 

Can I maybe extend the indexer programmatically with defines that are
not explicitly defined for the build process? Hints are appreciated.

For both the indexer preferences were set to the default under Eclipse
3.4.0 with CDT and the internal builder is used. 



Back to the top