bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdint_.h vs intmax_t & uintmax_t


From: Mark D. Baushke
Subject: Re: stdint_.h vs intmax_t & uintmax_t
Date: Tue, 15 Nov 2005 02:44:52 -0800

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Eggert <address@hidden> writes:

> "Mark D. Baushke" <address@hidden> writes:
> 
> > There is one remaining interaction with stdint_.h and config.h
> > which arises from m4/size_max.m4
> >
> > % grep SIZE_MAX config.h 
> > config.h:#define SIZE_MAX 4294967295U
> > % grep SIZE_MAX lib/stdint_.h
> > #define SIZE_MAX (~(size_t)0)
> 
> Thanks for mentioning that.  The obvious workaround is to ifdef
> SIZE_MAX as well.  Something like this.

Yes, the obvious patch works for my FreeBSD 4.2-RELEASE box, although I
suspect it would be more portable to use this:

    #ifndef SIZE_MAX
    # define SIZE_MAX ((size_t)-1)
    #endif

because ((size_t)-1) will work even if size_t is narrower than int.

I'll leave it to you folks to determine the best solution.

        Thanks!
        -- Mark

> I'd like Bruno's opinion on all this before installing into gnulib.
> 
> 2005-11-14  Paul Eggert  <address@hidden>
> 
>       * lib/stdint_.h (intmax_t) [defined intmax_t]: Do not declare.
>       (uintmax_t) [defined uintmax_t]: Do not declare.
>       (SIZE_MAX) [defined SIZE_MAX]: Do not define.
>       This works around a problem if intmax_t.m4 and/or uintmax_t.m4
>       and/or size_max.m4 are also used.  Problem reported by Mark D. Baushke.
> 
> --- stdint_.h.~1.7.~  2005-05-23 03:22:39.000000000 -0700
> +++ stdint_.h 2005-11-14 22:55:22.000000000 -0800
> @@ -133,11 +133,19 @@ typedef unsigned long uintptr_t;
>  /* 7.18.1.5. Greatest-width integer types */
>  
>  #ifdef _STDINT_H_HAVE_INT64
> +# ifndef intmax_t
>  typedef int64_t  intmax_t;
> +# endif
> +# ifndef uintmax_t
>  typedef uint64_t uintmax_t;
> +# endif
>  #else
> +# ifndef intmax_t
>  typedef int32_t  intmax_t;
> +# endif
> +# ifndef uintmax_t
>  typedef uint32_t uintmax_t;
> +# endif
>  #endif
>  
>  /* 7.18.2. Limits of specified-width integer types */
> @@ -230,7 +238,9 @@ typedef uint32_t uintmax_t;
>  #define SIG_ATOMIC_MIN 0
>  #define SIG_ATOMIC_MAX 127
>  
> -#define SIZE_MAX (~(size_t)0)
> +#ifndef SIZE_MAX
> +# define SIZE_MAX (~(size_t)0)
> +#endif
>  
>  /* wchar_t limits already defined in <stddef.h>.  */
>  /* wint_t limits already defined in <wchar.h>.  */
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFDebwkCg7APGsDnFERAkdSAJ99tFwK3Xkxt9PQ8dWOpoQA9L7GNwCgvPlf
CNKBEmJDKW4yPEbFhMgSoRE=
=elMP
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]