Including <limits.h> in gmp-impl.h

Torbjorn Granlund tg at
Wed Dec 25 12:28:20 UTC 2013

Vincent Lefevre <vincent at> writes:

  On 2013-12-25 12:13:39 +0100, Marc Glisse wrote:
  > Oups, looks like I already asked about that:
  > and the reply was to try including tests.h before gmp-impl.h.
  I'd say that it would be better to fix GMP. Reusing standard macros
  (even when there are not supposed to be defined under some conditions)
  is ugly. For instance, GMP_INT_MAX could be used instead of INT_MAX,
  and there would be no risk of clashes.
  Including tests.h before gmp-impl.h is probably not a good solution
  because in such tests, <limits.h> (from tests.h) may be used instead
  of GMP's definitions. So, if don't trust <limits.h>, that's incorrect.
  I'd also say that if <limits.h> is incorrect, lots of programs will
  fail to build correctly. So, GMP's trick to redefine limits will be
  useful only for users who use GMP in their own applications, without
  using <limits.h> in their applications either.

IIRC, limits.h was unreliable for many years, and our workarounds
allowed GMP to work on more systems.


More information about the gmp-devel mailing list