[RFC v2 1/3] cdefs: Add __bool
Alejandro Colomar
alx@kernel.org
Tue Sep 2 14:32:15 GMT 2025
Hi Florian,
On Tue, Sep 02, 2025 at 03:41:18PM +0200, Florian Weimer wrote:
> * Alejandro Colomar:
>
> > Signed-off-by: Alejandro Colomar <alx@kernel.org>
> > ---
> > misc/sys/cdefs.h | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
> > index 215ff937ee..1cd8f1e85b 100644
> > --- a/misc/sys/cdefs.h
> > +++ b/misc/sys/cdefs.h
> > @@ -57,6 +57,18 @@
> > # define __glibc_has_extension(ext) 0
> > #endif
> >
> > +#if defined __cplusplus
> > +# define __bool bool
> > +#elif defined __GNUC__ || defined __clang__
> > +# if __GNUC_PREREQ (3, 0)
> > +# define __bool _Bool
> > +# else
> > +# define __bool int
> > +# endif
> > +#else
> > +# define __bool _Bool
> > +#endif
>
> This changes ABI based on the detected compiler, so it's really not
> possible to do it this way.
Hmmmm, true. Can we drop support for compilers that don't have
_Bool/bool? That would be the easiest thing to do:
#if defined __cplusplus
# define __bool bool
#else
# define __bool _Bool
#endif
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250902/50ede07e/attachment.sig>
More information about the Libc-alpha
mailing list