gmp.h needs to detect bit width more dynamically to support universal builds on mac

Dan Kegel dank at
Tue Dec 3 04:46:33 UTC 2013

gmp version: gmp-5.1.3

On Mac, preferred way to deliver libraries is as 'fat' libraries
containing both 32 and 64 bit code.  This is easy to do with gmp,
just build gmp once for 32 bits and once for 64 bits, then combine
the libraries with the tool 'lipo'.  So far, so good, no changes needed in gmp.
But there is a small problem: to support this scheme,  the same gmp.h has to
be correct for use with both 32 and 64 bit code simultaneously.
That means that bit widths and the like must be computed using ifdef
when possible, and use the configure-generated values only as a fallback.

Examples of people doing this are legion, well, I found two easily:
(And it seems people get it wrong sometimes: )

The fix is easy.  Here's a patch that should Do The Right Thing, and
be completely safe for upstream:

Please have a look and let me know what you think.

More information about the gmp-bugs mailing list