API Shakeup: user data (was Re: [cairo] Patch improving fallbacks)

Kristian Høgsberg krh at bitplanet.net
Thu Feb 24 14:26:33 PST 2005


Owen Taylor wrote:
> On Thu, 2005-02-24 at 13:33 -0500, Carl Worth wrote:
> 
> 
>>>+typedef void (*cairo_destroy_func_t) (void *data);
>>
>>I think I'd prefer to have the '*' in the argument list rather than
>>swallowed up inside the typedef. I think this is consistent with my
>>general distaste for pointer-swallowing typedefs. But there may be a
>>compelling argument for a function-pointer exception to the
>>rule. Anyone have one?
> 
> 
> Do you know of any examples of libraries that don't swallow the
> * inside function typedefs? I can't think of ever seeing that,
> to the point I had to try it out to be sure that:
> 
>  typedef void (cairo_destroy_func_t) (void *data);
> 
> is even legal C. It would certainly be inconsistent with the GTK+
> stack.
> 
> The above typedef is also weird because it defines something
> that can't be used in isolation.

Well, it can, you can use it to declare a function prototype:

	cairo_destroy_func_t destroy_something;

that is, it's equivalent to

	void destroy_something (void *data);

(modulo the name of the argument, I guess).  It's not something you see 
everyday, though...

cheers,
Kristian



More information about the cairo mailing list