Add C2x BOOL_MAX and BOOL_WIDTH to limits.h
Florian Weimer
fw@deneb.enyo.de
Thu Aug 20 07:45:46 GMT 2020
* Joseph Myers:
> C2x adds BOOL_MAX and BOOL_WIDTH macros to <limits.h>. This patch
> adds them to glibc's <limits.h> for the case when they aren't defined
> by GCC's <limits.h>.
>
> Tested for x86_64.
>
> diff --git a/include/limits.h b/include/limits.h
> index 8195da78a4..29e9b943b9 100644
> --- a/include/limits.h
> +++ b/include/limits.h
> @@ -178,6 +178,18 @@
> # endif
> #endif /* Use IEC_60559_BFP_EXT. */
>
> +/* The macros for _Bool are not defined by GCC's <limits.h> before GCC
> + 11, or if _GNU_SOURCE is defined rather than enabling C2x support
> + with -std. */
> +#if __GLIBC_USE (ISOC2X)
> +# ifndef BOOL_MAX
> +# define BOOL_MAX 1
> +# endif
> +# ifndef BOOL_WIDTH
> +# define BOOL_WIDTH 1
> +# endif
> +#endif
Do you know why the width should be 1 and not any other value?
If it has to be 1, irrespective of the storage size, why doesn't the
draft say so?
More information about the Libc-alpha
mailing list