[cairo] forward declaration

Ian Britten britten at caris.com
Fri Apr 24 10:20:27 PDT 2009

Jonathon Jongsma wrote:

>> Hi, everyone.  I've got a problem on forward declaration.  In my 
>> drawinghelper.h, i wrote my code like this but compilation fails.  g++ 
>> complains "Cairo not declared".

>> class Context;
>> template <typename T>
>> class RefPtr;

> This is a general C++ error, not directly related to cairo / cairomm.  If you want to 
> forward-declare a namespaced variable, you need to forward-declare it in the namespace as 
> well, e.g.:
> namespace Cairo {
> class Context;
> }

Since this topic came up, I'll post a request:  :)

Would cairomm be willing to provide a 'forward declaration' file,
specifically for use in these situations?  It would simply contain
the proper forward declarations of the various cairomm classes,
properly namespaced.

We do this with our software, specifically to address this issue.
Users can just #include the 'fordec.h' file in situations where they
only need/want forward declarations, instead of pulling in the full
header file.  By having the software provide (And maintain) the
file, it means less chance of the caller getting it wrong, etc.

Anyways, just a suggestion...

More information about the cairo mailing list