Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer and "grey-background" problems with #ifdef in includes
Indexer and "grey-background" problems with #ifdef in includes [message #230410] Tue, 17 February 2009 13:00 Go to next message
Harald    is currently offline Harald Friend
Messages: 37
Registered: July 2009
Member
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 #230461 is a reply to message #230410] Wed, 18 February 2009 08:02 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
> But what options have I to force the parsing
> of the includes with SOURCE_X defined?

> Any hints?

> harald
You can add the DEFINE to your Eclipse configuration.
Project Properties -> C/C++ General -> Paths and Symbols -> Symbols

Axel


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer and "grey-background" problems with #ifdef in includes [message #230468 is a reply to message #230461] Wed, 18 February 2009 11:00 Go to previous messageGo to next message
Harald    is currently offline Harald Friend
Messages: 37
Registered: July 2009
Member
Axel Mueller wrote:

>> But what options have I to force the parsing
>> of the includes with SOURCE_X defined?
>> Any hints?

> You can add the DEFINE to your Eclipse configuration.
> Project Properties -> C/C++ General -> Paths and Symbols -> Symbols

Thank you for your reply. But thats not the solution. If we do that, the
DEFINE is global defined in the compiler settings for all C sources. The
intended use is lost. We want to use the DEFINE only in one including C
source. There we define the DEFINE before we include the file. In all
other C sources the include is included without the DEFINE.

Any other hints?

Harald
Re: Indexer and "grey-background" problems with #ifdef in includes [message #652323 is a reply to message #230468] Thu, 03 February 2011 15:19 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: February 2011
Junior Member
Is there any way that I can force Eclipse to simply ignore the #ifdef?
Re: Indexer and "grey-background" problems with #ifdef in includes [message #742910 is a reply to message #652323] Fri, 21 October 2011 00:25 Go to previous messageGo to next message
Vidya  is currently offline Vidya Friend
Messages: 9
Registered: November 2010
Junior Member
Hi,

I am facing the same problem. Is there anyway to simply ignore the #ifdef, while indexing?

Thanks
Vidya
Re: Indexer and "grey-background" problems with #ifdef in includes [message #912851 is a reply to message #230410] Fri, 14 September 2012 09:31 Go to previous message
Mahesh Kedari is currently offline Mahesh KedariFriend
Messages: 3
Registered: September 2012
Junior Member
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?
Previous Topic:Type not found across project references
Next Topic:get the list of sources files which exist in eclipse project explorer using CDT
Goto Forum:
  


Current Time: Thu Oct 10 16:17:16 GMT 2024

Powered by FUDForum. Page generated in 0.05058 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top