Bug 4196 - compile warning: MIN/MAX redefined
Summary: compile warning: MIN/MAX redefined
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 0.9.3
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-22 16:01 UTC by Christian Biesinger
Modified: 2006-06-13 16:51 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
patch (656 bytes, patch)
2005-08-22 16:02 UTC, Christian Biesinger
Details | Splinter Review

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.