Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » indexer doesn't track active configuration for #ifdefs
indexer doesn't track active configuration for #ifdefs [message #1768218] Fri, 14 July 2017 18:39 Go to next message
Andrew Voelkel is currently offline Andrew VoelkelFriend
Messages: 17
Registered: September 2016
Junior Member
Hi,

I've got a project with several build configurations which have different preprocessor symbols defined in "paths and symbols" for the different build configurations. But the indexer doesn't seem to know when I've changed the active configuration and reflect that in the way it "greys out" code depending on the setting of #ifdefs and #ifndefs that have been defined in the "paths and symbols" section of the build configuration.

This seems odds because I would think this would be a commonly used feature. Do I need to do something special to tell Eclipse to index according to a specific build configuration?

- Andy
Re: indexer doesn't track active configuration for #ifdefs [message #1768259 is a reply to message #1768218] Sun, 16 July 2017 06:39 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I haven't look at the code but AFAIK the indexer has only one cache.
If a macro has multiple values the last value encountered will be used.
This makes the value appear to be random.

Not sure if this would work:
You could try using a Preprocessor Macros File or maybe an Include File in the User Settings Entries tab
of Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
Use a name that has the current configuration name
Something like: MacrosFor${config_name:${ProjName}}.h (or maybe $(ConfigName) )
The file probably should undefine all macros before setting their values.

You may need to hit the apply button after changing the configuration.
You may also need to rebuild the index too.


[Updated on: Sun, 16 July 2017 07:22]

Report message to a moderator

Re: indexer doesn't track active configuration for #ifdefs [message #1768283 is a reply to message #1768259] Sun, 16 July 2017 22:03 Go to previous messageGo to next message
Andrew Voelkel is currently offline Andrew VoelkelFriend
Messages: 17
Registered: September 2016
Junior Member
Hi and thanks for the reply!

I'm not sure I completely understand your reply, mostly because I don't have a macro that is set multiple times. I just have a macro that is only set in one configuration. Let's call it SPECIAL_CONFIG, which I add to the "paths and symbols" of the "Special" configuration (and I don't give it any value)

But when I set the active configuration to "Special", the indexer doesn't seem to know that SPECIAL_CONFIG is defined in a source file:

#ifdef SPECIAL_CONFIG
// indexer "greys out" anything in here.
#endif

So it isn't a matter of SPECIAL_CONFIG being set more than once. I'm confused because this seems like a very basic use case. Telling Eclipse to rebuild the index after changing the active configuration doesn't seem to help.

- Andy

[Updated on: Sun, 16 July 2017 22:06]

Report message to a moderator

Re: indexer doesn't track active configuration for #ifdefs [message #1768286 is a reply to message #1768283] Mon, 17 July 2017 02:53 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Well, the macro has two values or states: defined and not defined.
You will need to actively cause the indexer to scan and also actively change the state of the definition.
One way which may work is to manually rebuild the index after changing the configuration.

There is an option to use the active build configuration.
However, that seems to only tell the indexer which files to scan when building the index .
It doesn't necessarily cause an automatic rebuild.

There is also an undocumented checkbox for rebuilding the index on a configuration change.
(Reindex project on change of active configuration).
This option is at least in Neon.3 and Oxygen and seems to be set by default.
You could try setting it if not already set.
As I said, it's undocumented.
If a manual rebuild doesn't work then this setting probably won't either.

The indexer options are found in Project --> Properties --> C/C++ General --> Indexer
http://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_idx.htm

and Window --> Preferences --> C/C++ --> Indexer
http://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_indexer_preference.html

[Updated on: Mon, 17 July 2017 02:57]

Report message to a moderator

Previous Topic:Eclipse cdt debugging an executable within a shell script
Next Topic:Moving executable
Goto Forum:
  


Current Time: Fri Mar 29 12:55:51 GMT 2024

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

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

Back to the top