Type of USHRT_MAX

Leif Leonhardy not.really at online.de
Sun Jun 9 01:16:02 CEST 2013


Marc Glisse wrote:
> Hello,
>
> according to the C standard, USHRT_MAX has type int (or unsigned int if
> short and int have the same size). __GMP_USHRT_MAX has type unsigned
> short. GMP sometimes defines USHRT_MAX as __GMP_USHRT_MAX, and always
> assumes that USHRT_MAX has type unsigned short (in printf in
> particular). This seems to only affect the testsuite, but it would still
> be nice to fix (some compilers give warnings).
>
> Should __GMP_USHRT_MAX be defined to ((unsigned int)current_definition)
> and the 'h' in printf format strings removed, or should USHRT_MAX be
> cast to (unsigned short) where needed? Or something else?

I'd go with "%hu",(unsigned short)USHRTMAX, which IMHO is more logical, 
since USHRTMAX should fit into an unsigned short. ;-)


-leif

-- 
() The ASCII Ribbon Campaign
/\   Help Cure HTML E-Mail


More information about the gmp-bugs mailing list