[RFC v4 1/4] cdefs: Add __bool

Paul Eggert eggert@cs.ucla.edu
Sun Sep 14 17:46:42 GMT 2025


On 2025-09-14 08:42, Alejandro Colomar wrote:
> On Sun, Sep 14, 2025 at 10:57:03AM -0400, Zack Weinberg wrote:
>> On Sun, Sep 14, 2025, at 2:01 AM, Alejandro Colomar wrote:
>>> +#if defined __cplusplus
>>> +# define __bool  bool
>>> +#else
>>> +# define __bool  _Bool
>>> +#endif
>> Serious question: should this be this, or should it instead be
>>
>> #if defined __cplusplus
>> # define __bool  bool
>> #elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
>> # define __bool  _Bool
>> #else
>> # error "GNU libc requires a C compiler that supports ISO C 1999"
>> #endif
>>
>> ? I can make an argument either way.
> I think I prefer the latter.  Otherwise, users might be surprised by
> weird compiler errors due to not having a definition of __bool, but they
> have never explicitly asked for it.

But what about compilers that don't define __STDC_VERSION__, even though 
they have _Bool? gcc -std=gnu90 still does this, and I don't see why 
cdefs should prohibit that here.

These days, anybody using a flag like -std=gnu90 should know exactly 
what's going on. We aren't talking C newbies here. So it's OK for these 
diagnostics to require some understanding of how C works.


More information about the Libc-alpha mailing list