Simplify preprocessor conditional syntax

We never do #ifdef-type conditions on CAIRO_HAS_* macros, because we
want to allow setting them to zero.  Then if we need to enable a feature
if either of PS or PDF is enabled, the proper syntax is:

	#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE

This works because the preprocessor replaces any unknown identifiers with
zero.  Some versions of gcc had a bug that got them very confused with
complex versions of the above.  As a workaround for that I have been using
the uglier version:

	#if CAIRO_HAS_PS_SURFACE+0 || CAIRO_HAS_PDF_SURFACE+0

which magically worked around that bug.  Or more recently replacing that
with the duplicated version:

	#if CAIRO_HAS_PS_SURFACE
	...
	#endif
	#if CAIRO_HAS_PDF_SURFACE
	...
	#endif

Both are uglier than the original.  Since the gcc bug was very short lived
and there's lots of software out there relying on the original form to work,
moving back to the simple version seems harmless.
This commit is contained in:
Behdad Esfahbod 2008-09-24 14:55:20 -04:00
parent adece69ae3
commit bb125689d3

View file

@ -72,20 +72,11 @@
#include "cairo-compiler-private.h"
#if CAIRO_HAS_PS_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_PDF_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_SVG_SURFACE
#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE || CAIRO_HAS_SVG_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_PS_SURFACE
#define CAIRO_HAS_PDF_OPERATORS 1
#endif
#if CAIRO_HAS_PDF_SURFACE
#if CAIRO_HAS_PS_SURFACE || CAIRO_HAS_PDF_SURFACE
#define CAIRO_HAS_PDF_OPERATORS 1
#endif
@ -2364,7 +2355,7 @@ cairo_private int
_cairo_ucs4_to_utf8 (uint32_t unicode,
char *utf8);
#if CAIRO_HAS_WIN32_FONT+0 || CAIRO_HAS_QUARTZ_FONT+0 || CAIRO_HAS_PDF_SURFACE+0
#if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_SURFACE
# define CAIRO_HAS_UTF8_TO_UTF16 1
#endif
#if CAIRO_HAS_UTF8_TO_UTF16