Search code examples
c++cmacroseclipse-cdtds-5

How to find where a macro is defined in a project?


I have a project with dozens of source module and dozens header files, some are nested. Working with ARM's Eclipse for DS-5 I get an error indication from the Indexer but not from the compiler.

The IDE complains that the FALSE macro in one of the source modules of a static library is undefined. However, it does compile OK.

In a 2nd project on the same codebase (another static library) there is no such problem.

Searching through the whole workspace there are multiple definitions in multiple headers for this macro. How can I trace which specific definition is the one that takes effect in the code?

Note - I found this similar question regarding MSVS and a nice trick as an answer, but is there a direct way to achieve this in Eclipse?


Solution

  • OK, I found the answer:

    1. Select the macro
    2. Right-click and select "Explore Macro Expansion" (or Ctrl+=)
    3. In the dialog window that opens, click the button at the bottom "Open Declaration"

    The place of declaration now opens in the editor.