parsing of c++ template definitions in separate files

Milian Wolff mail at milianw.de
Thu Apr 26 15:50:29 BST 2012


On Thursday 26 April 2012 09:39:41 Raimar Sandner wrote:
> Hi,
> 
> I'm working with a project where most template definitions are in separate
> *.tpp files (kdevelop-4.3.1). A minimal example follows:
> 
> --------------------------------------------------------
> The file main.cpp:
> --------------------------------------------------------
> #include "foo.h"
> 
> int main(int argc, char **argv) {
>   Foo<1> f;
> }
> --------------------------------------------------------
> The file foo.h:
> --------------------------------------------------------
> #ifndef FOO_H
> #define FOO_H
> 
> template<int R>
> struct Foo
> {
>   void bar();
> };
> #include "foo.tpp"
> #endif // FOO_H
> 
> --------------------------------------------------------
> The file foo.tpp:
> --------------------------------------------------------
> template<int R>
> void Foo<R>::bar()
> {
> }
> --------------------------------------------------------
> 
> Now when I edit foo.tpp, the semantic analysis cannot resolve the class
> Foo<R> unless I #include "foo.h". I would like to avoid this workaround
> because I would need to maintain a private branch of the project. Is there
> any other way to tell the parser that when editing foo.tpp it should parse
> foo.h along with it?

The only thing you could do is wrapping the #include in

#ifdef IN_IDE_PARSER
#include "foo.h"
#endif

If the project you are working on does not allow this to be checked in, then 
you are out of luck.

Bye

-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20120426/97f0f787/attachment.sig>


More information about the KDevelop mailing list