[cairo] "operator" keyword in libcairo

Owen Taylor otaylor at redhat.com
Wed Jan 19 07:33:12 PST 2005


On Wed, 2005-01-19 at 08:06 -0500, Carl Worth wrote:
> On Wed, 29 Dec 2004 11:07:31 -0800, Stuart Parmenter wrote:
> > The problem is that the GDI+ backend code needs the cairoint code to
> > not use operator anywhere.  I never checked in that patch cause keith
> > and carl didn't really want it, but it needs to go in at some point to
> > allow backends to ever be written using C++.
> 
> I don't recall the specific conversation, but I can certainly imagine
> grumbling about C++ requirements forcing me to change my C code. In
> spite of that, I certainly don't want the build to be broken for some
> users.
> 
> I notice that cairoint.h currently doesn't have the extern "C" stuff
> that cairo.h has. Would that help? If so, I'd be happy to add that
> rather than renaming things.

That needs to be done if there will be C++ source files (not clear
yet), and won't hurt in any case.

But it doesn't help with bad keywords ... extern "C" is just about
whether function names get mangled; it doesn't affect the use of
keywords. 'operator' and 'class' are really the only two that cause
problems, it's not hard to avoid them,

> Fixing cairo.h to use "op" in place of "operator" was simple as it's
> just a change to a prototype. We could do something similar in
> cairoint.h, but that would change a field in a structure which would
> ripple through every usage of gstate->operator in the implementation.
> 
> I can accept that if there's no other way, but I don't have to like
> it. I really prefer to have consistent naming for a line of code like:
> 
> 	cairo_operator_t operator = CAIRO_OPERATOR_OVER;
> 
> I'd almost prefer to find a substitute word rather than do
> inconsistent abbreviation like:
> 
> 	cairo_operator_t op = CAIRO_OPERATOR_OVER;
> 
> But "operator" really is the right word, (both mathematically and from
> following the Porter/Duff paper).

Remember, it's only the header files. You can call the parameter
different things in the source files and the headers if you want.

What we do in the GTK+ headers for the different problem of conflicts
with standard C library names ('index' being a common one) is to 
append an underscore and call the variable index_. It is pretty 
ignorable and avoids having 'idx' in one place 'indx' in another...

(For 'class', for historical reasons we use 'klass')

Regards,
					Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050119/a2c5cdf4/attachment.pgp


More information about the cairo mailing list