This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix UINT{8,16}_C


On Jul  3 06:10, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to Corinna Vinschen on 7/3/2006 3:41 AM:
> >   
> > 
> > I have checked the stdint.h headers on glibc 2.3.4 and 2.4, as well as
> > on Solaris 10, NetBSD, FreeBSD and OpenBSD.  Only FreeBSD and OpenBSD
> > define them as just x, all others as x##U, one way or the other.
> 
> And gnulib rejects Solaris 10 and glibc's versions as buggy as well:
> 
> http://lists.gnu.org/archive/html/bug-gnulib/2006-06/msg00118.html
> 
> > 
> > ISO/IEC 9899:TC2 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf)
> > has the following to say:
> > 
> >   7.18.4.1 Macros for minimum-width integer constants
> > 
> >   The macro INTN_C(value) shall expand to an integer constant expression
> >   corresponding to the type int_leastN_t.
> 
> The problem is that there is no integer constant expression for unsigned
> char; instead, you get an integer constant expression for the type that
> unsigned char promotes to.  Therefore, UINT8_C should give an int, not
> unsigned int.
> 
> This snippet from gnulib is valid C code, but fails if you use the wrong
> type specifier:
> 
>   /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
>   int check_UINT8_C:
> 	(-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
>   int check_UINT16_C:
> 	(-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;

Convinced.  I checked in your patch.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]