Search code examples
c++eclipseeclipse-cdteclipse-luna

C++ preprocessor variable defined in project configuration in eclipse, but invisible to C++ indexer


I use preprocessor variables to detect whether code is built for tests or production (I'm aware that you souldn't do this, but that's not the issue).

I have added an emc_test preprocessor variable in Project -> C++ General -> Paths and Symbols -> # Symbols, but C++ indexed doesn't see it, which results in blocks guarded by #ifdef emc_test being grayed out and sybmols inside aren't visible code completion.


Solution

  • In my case I had two build configurations one for tests (with emc_test defined) and another for release. I had assumed that C++ index will use whatever configuration is active, and this was not the case.

    In C++ General -> Indexer there is entry that controls which configuration is the source of C++ preprocessor symbols. And by default eclpise had "Use fixed build configuration" selected.

    Screenshot od the setting