bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MIN macro in numbers.c causes build problems on HP-UX


From: Andreas Vögele
Subject: MIN macro in numbers.c causes build problems on HP-UX
Date: Sun, 25 Apr 2004 17:04:02 +0200

On HP-UX, the macros MIN and MAX are defined in sys/param.h which is
included by limits.h.  There's an unconditional definition of MIN in
the CVS version of numbers.c which clashes with HP's definition.
Here's the error message:

./guile-snarf -o numbers.x numbers.c -DHAVE_CONFIG_H
-I.. -I.. -I../libguile-ltdl -g -fno-strict-aliasing -Wall
-Wmissing-prototypes -Werror
numbers.c:1797:1: "MIN" redefined
[...]
/usr/include/sys/param.h:420:1: this is the location of the previous
definition

I suggest to remove the MIN macro from numbers.c.  Instead, the lower
case macro min, which is definded in _scm.h anyway, can be used.
I'm wondering why the MIN macro was introduced at all.

Here's a patch:

Index: numbers.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/numbers.c,v
retrieving revision 1.238
diff -u -r1.238 numbers.c
--- numbers.c   22 Apr 2004 01:21:39 -0000      1.238
+++ numbers.c   25 Apr 2004 14:48:23 -0000
@@ -1794,8 +1794,6 @@
 #undef FUNC_NAME
 
 
-#define MIN(x,y)  ((x) < (y) ? (x) : (y))
-
 SCM_DEFINE (scm_bit_extract, "bit-extract", 3, 0, 0,
             (SCM n, SCM start, SCM end),
            "Return the integer composed of the @var{start} (inclusive)\n"
@@ -1824,7 +1822,7 @@
 
       /* When istart>=SCM_I_FIXNUM_BIT we can just limit the shift to
          SCM_I_FIXNUM_BIT-1 to get either 0 or -1 per the sign of "in". */
-      in = SCM_SRS (in, MIN (istart, SCM_I_FIXNUM_BIT-1));
+      in = SCM_SRS (in, min (istart, SCM_I_FIXNUM_BIT-1));
 
       if (in < 0 && bits >= SCM_I_FIXNUM_BIT)
        {
@@ -1839,7 +1837,7 @@
        }
 
       /* mask down to requisite bits */
-      bits = MIN (bits, SCM_I_FIXNUM_BIT);
+      bits = min (bits, SCM_I_FIXNUM_BIT);
       return SCM_MAKINUM (in & ((1L << bits) - 1));
     }
   else if (SCM_BIGP (n))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]