[cairo] Problem with C++ and cairo_path_data_t

Jason Dorje Short jdorje at users.sf.net
Thu Jun 9 11:15:07 PDT 2005


Owen Taylor wrote:
> On Sat, 2005-06-04 at 18:18 -0400, Jason Dorje Short wrote:
> 
>>T Rowley wrote:
>>
>>>Trying to write some code very similar to the example of walking through
>>>a cairo_path_t as shown in cairo.h, I've come across the problem that
>>>the enumerators CAIRO_PATH_* are not visible when using C++.
>>
>>You can't have embedded enumerations in C++; the enumerated values
>>aren't visible outside of the embedding.  See
>>
>>  http://david.tribble.com/text/cdiffs.htm#C99-nested-struct
>>
>>The best fix is probably to unembed the enumeration, which this patch
>>does.  It's also possible in C++ to refer to the embedded enumeration
>>using the scope (something like
>>cairo_path_data_t::header::CAIRO_PATH_MOVE_TO), but that's ugly and the
>>resulting code won't work under C.
> 
> +typedef enum cairo_path_type_t {
> +    CAIRO_PATH_MOVE_TO,
> +    CAIRO_PATH_LINE_TO,
> +    CAIRO_PATH_CURVE_TO,
> +    CAIRO_PATH_CLOSE_PATH
> +} cairo_path_type_t;
> 
> Hmm, isn't this name a bit weird? (It's not the type of the path).
> Maybe cairo_path_operation_t? That's long, but there should (almost)
> never be variables of the type, so it doesn't really matter.

Sure.  Changing the name is easy enough.  Since verbosity isn't an issue
maybe cairo_path_data_operation_t would be okay.

-jason



More information about the cairo mailing list