INT_MAX definition in gmp-impl.h conflicts with limits.h

Torbjorn Granlund tg at
Wed Nov 23 13:30:41 CET 2011

Marc Glisse <marc.glisse at> writes:

  I was compiling gmp with clang (no issue except for the use of jb,pt
  in mpn/x86_64/mod_34lsub1.asm), and then I ran the testsuite and hit
  this issue: on linux, limits.h includes bits/xopen_lim.h which
  contains this code:
  #ifdef INT_MAX
  # if INT_MAX == 32767
  #  define WORD_BIT      16
  On the other hand, gmp-impl.h defines INT_MAX as something not
  preprocessor-friendly (with casts). The combination doesn't work. I
  can work around it by including tests.h before gmp-impl.h in the C++
  test files, but that doesn't feel right.
  Any opinion on the best way to go about this?

Why is only one compiler affected?  Does GMP somehow #include different
files for different compilers?


More information about the gmp-bugs mailing list