Bug 4196

Summary: compile warning: MIN/MAX redefined
Product: cairo Reporter: Christian Biesinger <cbiesinger>
Component: generalAssignee: Carl Worth <cworth>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: high CC: jwatt
Version: 0.9.3   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: patch

Description Christian Biesinger 2005-08-22 16:01:36 UTC
if some header defines MIN/MAX before cairoint.h is included, it causes a
compile warning because cairoint.h defines these two unconditionally. The
definitions for TRUE/FALSE have an #ifndef around them, I think MIN/MAX should too.
Comment 1 Christian Biesinger 2005-08-22 16:02:08 UTC
Created attachment 2995 [details] [review]
patch
Comment 2 Carl Worth 2005-08-22 17:15:18 UTC
Move bugs against "cvs" version to "0.9.3" so we can remove the "cvs" version.
Comment 3 Owen Taylor 2005-08-27 18:46:40 UTC
For GLib, we made the decision that TRUE / FALSE can only be defined one way, 
so use #ifndef, #define, but MIN/MAX might conceivably have different
definitions, so what we do there instead is 

#undef  MIN
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))

Other definitions could be specific to some types, try to avoid multiple
evaluation, or whatever. I would suggest the same for Cairo. 

In fact, it's well enough tested for GLib that I'll just go ahead and
do it, even if it looks a little strange to do different things for
TRUE/FALSE and MIN/MAX.

2005-08-27  Owen Taylor  <otaylor@redhat.com>

        * src/cairoint.h: Undef MIN/MAX before defining them in case
        some system header happens to define them. (#4196, Christian
        Biesinger)


Comment 4 Richard Lloyd 2005-10-20 04:25:43 UTC
Just a note that I'm reopening this bug because the following files have the
same problem in cairo 1.0.2 (i.e. redefining MIN/MAX without undef'ing first,
which causes a gcc 4.0.2 compiler warning for me on HP-UX 11.X):

pixman/src/icint.h
pixman/src/pixregion.c
Comment 5 Carl Worth 2006-06-13 16:51:23 UTC
Thanks.

I just fixed these two files as well, (in the same undef style as used in
cairoint.h).

-Carl

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.