Compilation fails when inttypes.h without uint_least32_t definition present but stdint.h with definition present

Marc Glisse marc.glisse at
Mon May 24 08:31:05 UTC 2021

On Sun, 23 May 2021, Larkin Nickle wrote:

> Compilation of GMP fails when the system has an inttypes.h header without 
> uint_least32_t definition, even when there is a stdint.h with the definition 
> present.
> Starting at line 154 in gmp-impl.h:
> #if HAVE_INTTYPES_H      /* for uint_least32_t */
> # include <inttypes.h>
> #else
> #  include <stdint.h>
> # endif
> #endif
> Notice that if the system has inttypes.h, then stdint.h will not be included. 
> This is an issue on systems where the system has inttypes.h without a 
> uint_least32_t definition, but does have a fixed stdint.h generated by GCC 
> which does have a definition for it. Since stdint.h is only included when 
> inttypes.h isn't present, the fixed stdint.h isn't pulled in. A system known 
> to have this issue rear its head is Tru64.
> Tested on Tru64 5.1B with GMP 6.1.0, compiling with GCC 4.7.4.
> libtool: compile:  alphaev56-dec-osf5.1b-gcc -std=gnu99 -DHAVE_CONFIG_H -I. 
> -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_mp_bases -mieee -O2 -pedantic 
> -Wa,-arch,ev56 -mcpu=ev56 -c mp_bases.c  -DPIC -o .libs/mp_bases.o
> In file included from mp_bases.c:4:0:
> ../gmp-impl.h:232:1: error: unknown type name 'uint_least32_t'
> make[2]: *** [mp_bases.lo] Error 1
> If gmp-impl.h is edited to just pull in stdint.h, compilation continues.

This looks related

One option would be to have gcc fixinclude inttypes.h to make it include 
stdint.h, since that seems to be required for conformance, except that gcc 
pulled support for Tru64 almost 10 years ago...

There was a suggestion in the other thread to change GMP-6.* to include 
stdint.h if present, independently of inttypes.h (move the code outside of 
#else). That does look like a simple idea, I don't expect too many 
platforms to have conflicts between the 2 headers.

Marc Glisse

More information about the gmp-bugs mailing list