[cairo] [PATCH 6/8] Don't use bare #if on possibly
undefined preprocessor symbols
Carl Worth
cworth at cworth.org
Tue Jan 16 16:52:41 PST 2007
On Sun, 13 Aug 2006 05:52:03 -0400, Pavel Roskin wrote:
> On Sun, 2006-08-13 at 04:50 -0400, Behdad Esfahbod wrote:
> > This one I wanted to do too, but Carl doesn't like it. The problem with
> > using ifdef of course is that defining something to zero doesn't turn it
> > off.
>
> Actually, this patch only makes such change for the symbols starting
> with "HAVE_", which come from Autoconf generated config.h. It doesn't
> affect other symbols that may have a different semantic. I was only
> getting warnings about "HAVE_" symbols.
What makes the HAVE_ macros special that they were the only ones you
were getting warnings about?
For what it's worth, it's exactly these macros for which I care about
being able to use #if instead of #ifdef. For one thing, it just looks
so much better, but more signicantly, since users easily end up with
something like config.h that can say something like:
#define DISABLE_SOME_FLOATING_POINT 1
As Behdad mentioned, I don't want to break the natural means of
changing that, which would be to leave the #define but change the
value to 0.
> > I decided to take the warning flag out of my environment instead.
>
> That's why a reference to the non-existent __INT_MIN__ was never found.
So I see that as a separate problem, with a couple of different
answers:
1. Fix the checkers to restrict the warnings for undefined macros to
expressions where the arithmetic value is used, (rather than just
the Boolean condition).
2. Avoid using pre-processor arithmetic.
The pre-processor is a nasty language, there's no doubt. But let's
bear the pain of that as the developers of the code and not pass it
on to the users by using #ifdef when we aren't wanting to test whether
it's defined, but whether it's defined to a non-zero value.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070116/2dbe9af8/attachment.pgp
More information about the cairo
mailing list