On Mon, 23 Nov 2026, 23:16 Alejandro Colomar via Std-Proposals, <std-proposals@lists.isocpp.org> wrote:
Hi Andrey,

> Date: 2026-11-24 01:18:01+0300
> From: Andrey Semashev via Std-Proposals <std-proposals@lists.isocpp.org>
>
> 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@lists.isocpp.org>
> >>
> >> 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__,

Compilers often provide features in older dialects, so the language
version in which features are available is a bit uncertain.  It's more
robust to query for the feature itself.

Yes, and that's the problem with your countof example. You only queried if the header exists in the search path, not whether it provides the feature.

The header could guard all its content with a check for the value of __STDC_VERSION__ and so be effectively empty for older standards. The __has_include check would still pass, because the file does exist, but including it wouldn't give you the countof macro. 




> 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.

'#ifdef countof' or '#ifdef __has_include(<stdcountof.h>)' seem more
robust than a query of the feature through some other means. 

To be really robust you need both. Check if the header exists and include it if found. Then check if the 'countof' macro (or the header's own macro) is defined afterwards.


How do you
know what to pass to __has_feature()?  It's more well known what to pass
to #ifdef, or to query for a specific header file.

But yes, it'd be nice to have __has_feature().


Cheers,
Alex

--
<https://www.alejandro-colomar.es>
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals