[RFC v2 1/3] cdefs: Add __bool

Alejandro Colomar alx@kernel.org
Tue Sep 2 14:41:13 GMT 2025


On Tue, Sep 02, 2025 at 04:32:21PM +0200, Alejandro Colomar wrote:
> 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

Self-reply:

This seems entirely possible, given the glibc documentation requires
GCC 12.1 at least.
<https://sourceware.org/glibc/manual/latest/html_node/Tools-for-Compilation.html>

So, I'll simplify this.


Cheers,
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/c0955a7e/attachment.sig>


More information about the Libc-alpha mailing list