Hello,

trying to compile gmp with clang, I got this error in the C++ testsuite:

In file included from /usr/include/limits.h:152:
/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:97:7: error: token is not a valid
      binary operator in a preprocessor subexpression
#  if INT_MAX == 2147483647
      ^~~~~~~
/data/repos/gmp/gmp-impl.h:579:31: note: expanded from macro 'INT_MAX'
#define INT_MAX            (-(INT_MIN+1))
                              ^~~~~~~
/data/repos/gmp/gmp-impl.h:576:35: note: expanded from macro 'INT_MIN'
#define INT_MIN            ((int) UINT_HIGHBIT)
                            ~~~~~ ^
/data/repos/gmp/gmp-impl.h:564:28: note: expanded from macro 'UINT_HIGHBIT'
#define UINT_HIGHBIT       (UINT_MAX ^ ((unsigned) UINT_MAX >> 1))
                           ^

Something in the glibc headers doesn't like the gmp definitions of those macros. It is easily worked around by including limits.h in gmp-impl.h, but I see this comment:

/* limits.h is not used in general, since it's an ANSI-ism, and since on
   solaris gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong
   values (the ABI=64 values).

   On Cray vector systems, however, we need the system limits.h since sizes
   of signed and unsigned types can differ there, depending on compiler
   options (eg. -hnofastmd), making our SHRT_MAX etc expressions fail.  For
   reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and
   short can be 24, 32, 46 or 64 bits, and different for ushort.  */

#if defined _CRAY
#include <limits.h>
#endif


So even using autoconf to check if limits.h exists may not be enough. Or can we ignore the old solaris issue?

--
Marc Glisse
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to