[cairo] CAIROMM: Status type and Xlib

Jonathon Jongsma jonathon.jongsma at gmail.com
Thu Jan 12 06:41:53 PST 2006

In experimenting with implementing a heirarchy of surfaces in cairomm,
I've run across a problem that took me a while to track down.  cairomm
typedefs cairo_status_t as Cairo::Status.  This was working fine until
I added support for XlibSurface, which needs to pull in a bunch of
xlib headers.  The problem is that Xlib.h contains the line:

#define Status int

So any Status type that occurs after Xlib.h is included gets replaced
by the preprocessor with 'int'.  I don't know why it's a #define
instead of a typedef.  If it was a typedef, it would work fine since
Cairo's Status type is declared within the Cairo namespace.  But
obviously the preprocessor is not namespace aware so it simply
replaces it wherever it exists.  This creates a bunch of linking
problems because in some files the Status type gets treated as an int
and in some files it gets treated as a cairo_status_t.

The obvious solution to this issue is to rename the Status type in
cairomm, but it's slightly annoying that we have to worry about this
at all (since it's defined within a namespace precisely to avoid these
sorts of naming conflicts).  Is there any other way to work around
this?  Or any ideas for a new name?


More information about the cairo mailing list