C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Don't get rid of <stdbool.h>

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Tue, 24 Nov 2026 01:18:01 +0300
On 24 Nov 2026 01:02, Alejandro Colomar wrote:
> Hi Andrey,
>
>> Date: 2026-11-24 00:50:14+0300
>> From: Andrey Semashev via Std-Proposals <std-proposals_at_[hidden]>
>>
>> On 24 Nov 2026 00:44, Andrey Semashev wrote:
>>> On 24 Nov 2026 00:11, Frederick Virchanza Gotham via Std-Proposals wrote:
>>>>
>>>> I don't know if there are plans to deprecate <stdbool.h> and
>>>> <stdalign.h> now that they have been replaced with keywords in C, but
>>>> I'd just like to say that I think that they should be kept forever in
>>>> both C and C++, especially because there's such wide variety in what
>>>> standards of C are used (some still on C89).
>>>>
>>>> It's nice to be able to write a header file as follows:
>>>>
>>>> #include <stdbool.h>
>>>> extern bool Init(void);
>>>>
>>>> instead of having to do:
>>>>
>>>> #ifndef __cplusplus
>>>> # include <stdbool.h>
>>>> #endif
>>>> extern bool Init(void);
>>>>
>>>> I think it was a mistake for them to deprecate these headers in C23,
>>>> because now we have to do:
>>>>
>>>> #if !__cplusplus && __STDC_VERSION__ < 202311l
>>>> # include <stdbool.h>
>>>> #endif
>>>> extern bool Init(void);
>>>>
>>>> I think C should on undeprecate these headers, and I think C++ should
>>>> never deprecate them.
>>>
>>> Just don't include stdbool.h, ever. IMHO, that header is a mistake, not
>>> the fact it was deprecated.
>>
>> Apparently it was not deprecated. This doesn't change my opinion of it,
>> just means that it will remain a useless compatibility shim that
>> shouldn't have existed in the first place.
>>
>>> I think, the C's approach to introduce keywords as macros first does
>>> more harm than good.
>
> It has some nice side effects: you can test for the existence of the
> header (or of the macro) to know whether the feature is available:
>
> #if __has_include(<stdcountof.h>)
> # include <stdcountof.h>
> #else
> # define countof(a) (sizeof(a) / sizeof((a)[0]))
> #endif
>
> If you only have the keyword, then you need to complicate your build
> system.

Why do you need a header as a proxy for core language feature detection?
There is __STDC_VERSION__, and there can be predefined feature detection
macros, like we have in C++. (Yes, C++ messed up library feature macros
initially, before <version> was introduced, but at least we got these
right in the end.) There are also __has_feature and similar extensions
that could be standardized, if needed.

Received on 2026-11-23 22:18:07