Issue with parsing of conditionally compiled code or how to force parser to process the code under conditional compilation

Eugene Agafonov e.a.agafonov at gmail.com
Mon Jun 25 21:44:26 BST 2012


Hi!

I've faced an annoying issue with C++ parser. It does not enable
declaration-definition navigation if it decides the code is not compiled
due to conditional compilation.
It is really predictable behavior but it is an issue if macro is not
defined in any header file but defined as compiler command line option.

The main question is: Is it possible to tell the parser that some macro is
actually defined somewhere in universe and it shall threat it as defined
while parsing the source code.

Any way, it would be useful to set macro value for parsing  as it is done
for custom include paths.

Here is a code snippet to play with.
---8<----8<----8<----8<----

// Uncomment the line below to get the class parsed
// #define HAS_FEATURE

#ifdef HAS_FEATURE

class Test {
    // Declaration-definition navigation popup does not work until
HAS_FEATURE is defined. Uncomment line #2 to check
    void method();
};

// Declaration-definition navigation  popup does not work until HAS_FEATURE
is defined. Uncomment line #2 to check
void Test::method()
{

}

#endif

------8<----8<----8<----8<----

Put it in some folder and import as new 'Custom Makefile project'

Uncomment line #2 to get navigation popup working on Test::method()
declaration/definition.
With the snippet above I'd like to have some quite simple UI to mark macro
 HAS_FEATURE defined. It would be applicable for current folder only for
example, or folder with sub folders just like for custom include paths.

 "The issue" appears on both kdevelop's 4.3 branch and master as well.
Kdevplatform/kdevelop are build from source.
If it is already possible to to it is quite tricky to find it ;-)

Thanks a lot, Eugene Agafonov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20120626/7cc41088/attachment.html>


More information about the KDevelop mailing list