Patchwork util.h: define MIN macro only if it is not yet defined

login
register
mail settings
Submitter André Sintzoff
Date Jan. 21, 2018, 2:40 p.m.
Message ID <6330959c35f4128ed9b7.1516545623@zibeline.local>
Download mbox | patch
Permalink /patch/27022/
State Accepted
Headers show

Comments

André Sintzoff - Jan. 21, 2018, 2:40 p.m.
# HG changeset patch
# User André Sintzoff <andre.sintzoff@gmail.com>
# Date 1516545588 -3600
#      Sun Jan 21 15:39:48 2018 +0100
# Node ID 6330959c35f4128ed9b7b8d61b400251ecf2475a
# Parent  5f5fb279fd394c117fb64a95ad7fd1e4db72951d
util.h: define MIN macro only if it is not yet defined.

MIN macro is defined in <sys/param.h> on macOS Sierra.
Therefore as HAVE_BSD_STATFS is defined in osutil.c,
'MIN' macro redefined warning is emitted.
Gregory Szorc - Jan. 21, 2018, 6:06 p.m.
On Sun, Jan 21, 2018 at 6:40 AM, <andre.sintzoff@gmail.com> wrote:

> # HG changeset patch
> # User André Sintzoff <andre.sintzoff@gmail.com>
> # Date 1516545588 -3600
> #      Sun Jan 21 15:39:48 2018 +0100
> # Node ID 6330959c35f4128ed9b7b8d61b400251ecf2475a
> # Parent  5f5fb279fd394c117fb64a95ad7fd1e4db72951d
> util.h: define MIN macro only if it is not yet defined.
>

Queued, thanks.


>
> MIN macro is defined in <sys/param.h> on macOS Sierra.
> Therefore as HAVE_BSD_STATFS is defined in osutil.c,
> 'MIN' macro redefined warning is emitted.
>
> diff -r 5f5fb279fd39 -r 6330959c35f4 mercurial/cext/util.h
> --- a/mercurial/cext/util.h     Thu Jan 18 00:50:12 2018 +0100
> +++ b/mercurial/cext/util.h     Sun Jan 21 15:39:48 2018 +0100
> @@ -27,7 +27,9 @@
>  extern PyTypeObject dirstateTupleType;
>  #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType)
>
> +#ifndef MIN
>  #define MIN(a, b) (((a) < (b)) ? (a) : (b))
> +#endif
>  /* VC9 doesn't include bool and lacks stdbool.h based on my searching */
>  #if defined(_MSC_VER) || __STDC_VERSION__ < 199901L
>  #define true 1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff -r 5f5fb279fd39 -r 6330959c35f4 mercurial/cext/util.h
--- a/mercurial/cext/util.h	Thu Jan 18 00:50:12 2018 +0100
+++ b/mercurial/cext/util.h	Sun Jan 21 15:39:48 2018 +0100
@@ -27,7 +27,9 @@ 
 extern PyTypeObject dirstateTupleType;
 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType)
 
+#ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
 /* VC9 doesn't include bool and lacks stdbool.h based on my searching */
 #if defined(_MSC_VER) || __STDC_VERSION__ < 199901L
 #define true 1