Indexer and "grey-background" problems with #ifdef in includes [message #230410] |
Tue, 17 February 2009 08:00  |
Eclipse User |
|
|
|
Hello,
At work I've noticed two problems with the indexer. Let's start with a
snippet to explain.
There are two includes and two sources with the following content:
Step1.h:
01 #ifdef SOURCE_X
02 #include "Step2.h"
03 int variable1 = 0;
04 #else
05 extern int variable1;
06 #endif
Step2.h:
01 #ifdef SOURCE_X
02 int variable2 = 0;
03 #else
04 extern int variable2;
05 #endif
Main.c:
01 #define SOURCE_X
02 #include "Step1.h"
03 void doSomething(void)
04 {
05 variable1 = 4;
06 variable2 = 3;
07 }
AddOn.c
02 #include "Step1.h"
03 void doSpecial(void)
04 {
05 variable1 = 4;
06 }
In Main.c SOURCE_X is defined for the definitions of the global variables
in the two includes. In AddOn.c not. Step1.h includes Step2.h dependent on
SOURCE_X is defined.
Problem #1:
If the indexer starts with AddOn.c, SOURCE_X is not defined and the
variable2 is unknown. Code complete is not possible for this variable and
the declaration can't be opened with the key F3. F3 on variable1 jumps to
line 05 in Step1.h. I think the indexer parses the includes only once.
That's OK to keep time low. But what options have I to force the parsing
of the includes with SOURCE_X defined? Can I extend the indexer with
defines that are not part of the build? Adding Main.c to the indexer
preference "index up-front" helps, but is not suitable for large projects
and multiple includes in different Main.c's.
Problem #2:
If the indexer starts with Main.c problem #1 doesn't occurs. Code proposal
and jumping to the line 02 with F3 works fine, but the lines 01 and 02 are
greyed (background), i.e. the indexer has parsed line 02 but the editor
doesn't shows this.
For both the indexer preferences were set to the default under Eclipse
3.4.0 with CDT 5.0.2.200902060802.
Any hints?
harald
|
|
|
|
|
|
|
Re: Indexer and "grey-background" problems with #ifdef in includes [message #912851 is a reply to message #230410] |
Fri, 14 September 2012 05:31  |
Eclipse User |
|
|
|
I am also facing the same issue. Is there any workaround for this issue?
Below is my use case.
test.c
#ifdef ABCD
#include "a.h"
#else
#include "b.h"
#endif
If i build my project for first time, it will check the status of ABCD. If it is defined it will add "a.h" in dependency file "test.d".
Now if I go to Managed Build Setting and add ABCD in macro, and rebuild my project, everything works as expected except regeneration of "test.d" file.
So even if now ABCD is defined, my dependency file will check changes in "a.h" Instead of "b.h"
Can anybody please help me resolve this issue?
|
|
|
Powered by
FUDForum. Page generated in 0.06768 seconds