[cairo] Making pixman version available to cairo at compile-time

Carl Worth cworth at cworth.org
Tue Jan 22 09:50:48 PST 2008

So I can't stand it when cairo doesn't compile warning-free, (we turn
on all those compiler warnings so that we can fix the code of course).

The only current warnings (for me) are "enumeration value not handled
in switch".[*] Some of these warnings are due to new enumeration
values that have been added to pixman.

So I'd like to add the new pixman enumeration values to the switch
statements to squelch the warnings, but that will have a side-effect
of gratuitously breaking cairo builds against older versions of
pixman, which seems unkind.

If I had a compile-time mechanism for querying the pixman version,
then I could avoid breaking the build. So I propose adding macros in
the style of cairo's version macros. Specifically, that would be three
macros for each component:


and one macro with a combined numerical value:


which is defined in terms of a parameterizable
PIXMAN_VERSION_ENCODE(major, minor, micro) macro that is also
available to the user.

So in cairo I would then augment the switch statements with things

	case PIXMAN_yuy2: case PIXMAN_yv12:

While we're at this, we could even add run-time querying of the pixman
version by adding a pixman_version function, but I'm not sure who
would ever care about that. (I can't imagine cairo be able to do
anything useful with and cairo ends up hiding pixman entirely as an
implementation detail.) But for completeness it wouldn't hurt.

Anyone have any objection to that? If not, I'll cook up the obvious
patch and push.


[*] I have somewhat mixed feelings about this warning. I love that
when adding a new enumeration value the compiler tells me everywhere
that those values are being switched on so that I can ensure that each
case is considered properly. I don't love that we end up just copying
most of the whole list next of values next to "default:" for the
switches where there is a small whitelist of values and a default that
really can handle anything else, (including new values that get
created in the future). I guess what I'd maybe like is a way to just
selectively turn off that warning for particular switch statements.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080122/7ad1416e/attachment.pgp 

More information about the cairo mailing list