namespace, forward class definitions (and "using")

Kevin Funk kfunk at
Tue Apr 10 12:42:56 UTC 2018

On Tuesday, 10 April 2018 09:57:16 CEST René J.V. Bertin wrote:
> Hi,
> I ran into a snag in my experiments with the topcontexts implementation
> which is almost certainly caused by something I still don't grasp in
> KDevelop's use of namespaces.


I've read your mail twice and I still cannot figure out what exactly you're 
trying to do. The way your mail is written also makes it difficult to help you 
as there's no complete snippet one could compile on the quick.

You seem to be talking about an generic C++ problem which can be isolated into 
a simple standalone program which exhibits your problem. So why don't follow 
best-practices and create a minimal complete and verifiable example:

(This question is probably more geared towards a C++ programming community 
audience, at any rate)

> As mentioned, I started out by introducing a thin wrapper class (say,
> FooFile) to be used via an alias class declared as `using FooStorage =
> FooFile;`.
> My intention was to hide the details as much as possible in the
> implementation file (foodynamicdata.cpp), putting only enough in the
> foodynamicdata.h to be able to use the new classes in the exported
> declarations (`void writeData(FooStorage* store);` instead of `void
> writeData(QFile* file)`):
> // existing forward defs in namespace KDevelop
> class FooFile;
> class FooLMDB;
> using FooStorage = FooFile;
> //...
> void writeData(FooStorage* store);
> I also would like to avoid introducing a separate implementation file, for
> now.
> The snag is that I cannot figure out where to put the FooFile class forward
> def and its implementation in foodynamicdata.cpp to avoid a confusion
> between FooFile and KDevelop::FooFile .
> The rough outline of foodynamicdata.cpp is
> #include "foodynamicdata.h"
> using namespace KDevelop;
> namespace {
> // all code is here
> }
> In the end I've put a full instead of a forward definition of the FooFile
> class in the headerfile. What am I missing here?
> Thanks,
> R.

Kevin Funk | kfunk at |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the KDevelop-devel mailing list