[Cairo] make error with cvs cairo

Bill Spitzak spitzak at d2.com
Tue Sep 16 12:06:21 PDT 2003

On Tuesday 16 September 2003 11:06 am, Carl Worth wrote:

>  > Getting Xlib out of any public header files is extremely important. It
>  > pollutes the namespace with many symbols and typedefs and macros.
> It's funny, I've never actually run into any problems with this in my
> own code. It must be that I have different natural naming conventions
> than those of the Xlib authors.

By far the worst one I ran into was when I changed fltk to use namespaces. I 
now had an object called fltk::Window. "using namespace fltk" caused all 
kinds of conflicts that would require me to identify every instance with 
either ::Window for the xlib stuff or fltk::Window for fltk.

I ended up using macros to fool the compiler into thinking the object being 
defined/used was called XWindow. The same was done for the word "atom", and I 
may have to do it for Display. In any case I figure this sort of hack is safe 
as long as xlib.h is included only internally by my code. Putting xlib.h into 
the public header file makes this solution impossible.

>  > I would prefer that void* or other standins be used in any
>  > structures that have a field for xlib objects.
> I don't want to give up typechecking though.

True. The main example I had was that in fltk people wanted to put cached 
Pixmap pointers into the public Image object. The only typesafe way to do 
this is to include xlib.h. Instead I declared these as void* and do the 
necessary but ugly casts internally to store a Pixmap id into that space.

> And really, I don't see the point. As I mentioned before, the main
> cairo.h header file will not include things like Xlib.h.

> As I said before, there are no useless typedefs in the public cairo.h
> header. The only things left today are a few opaque structs:
> 	typedef struct cairo cairo_t;
> 	typedef struct cairo_surface cairo_surface_t;
> 	typedef struct cairo_matrix cairo_matrix_t;
> and a handful of enum values.

Sounds good. I would make sure that anything that is only used by those 
opaque structures is not declared either. For instance if the fixed type is 
only used inside those structures, there is no need to put it in the header 
file either.

> That would let us drop all #includes from cairo.h except for
> fontconfig. To get rid of that, we just need to decide the header file
> in which those functions belong.

More information about the cairo mailing list