Making sure <gmp.h> and libgmp.* do match

Torbjorn Granlund tg at
Tue Oct 21 16:50:29 CEST 2008

Roberto Bagnara <bagnara at> writes:

  I have been bitten by the following problem on a bi-arch system.
  By accident, I was compiling with the 32-bit version of <gmp.h>
  and linking with the 64-bit version of libgmp.*.  The failure
  I got was not trivial at all (only one test out of thousands
  was failing), and debugging took a long time.
  Do you know a defense against this kind of errors?
  More specifically:
  - for version mismatches, the obvious thing to do is to
     compare the result of gmp_version() with the macros
  - I am wondering if something similar can be done for
     ABI mismatches: for example <gmp.h> defines
     __GMP_BITS_PER_MP_LIMB: does libgmp.* "leak"
     this information so that a comparison can be made?
There is a documented variable mp_bits_per_limb.


More information about the gmp-discuss mailing list