[cairo] Adding a boolean type

Owen Taylor otaylor at redhat.com
Mon Jan 31 16:02:45 PST 2005


Working with Cairo, I've gotten annoyed by using int/0/1 for booleans.
It makes the code harder to read to have to decipher what is an int
and what is a boolean.

What if we add:

 typedef char cairo_bool_t;
 #define CAIRO_FALSE 0
 #define CAIRO_TRUE  1

Issues:

 char vs. int: For Glib we picked int, to reduce the risk of
   'GBoolean bool = flags & FLAG' traps, but mostly it doesn't matter,
   and char seems to be more common in general.

 CAIRO_FALSE vs. FALSE: For GLib, FALSE/TRUE are pretty much the 
   only exception's to the namespace. We do:

     #ifndef FALSE 
     #define FALSE 0 
     #endif

   and I don't think we've ever had reports of problems. And the
   reduced typing is nice...

What do people think?
						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/20050131/5144455b/attachment.pgp


More information about the cairo mailing list