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

Roberto Bagnara bagnara at cs.unipr.it
Tue Oct 21 16:04:31 CEST 2008


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
   __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
   __GNU_MP_VERSION_PATCHLEVEL;

- 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?

Thanks,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it


More information about the gmp-discuss mailing list