Re: git: 8d29d2429649 - main - libc: Restore prior C23 include guards

From: Mark Millard <marklmi_at_yahoo.com>
Date: Wed, 26 Aug 2026 05:47:47 UTC
On 8/25/26 19:51, Devin Teske wrote:
> : at_start: {auth_results {shxd.cx}}
> 
> 
>> On Aug 25, 2026, at 10:34 AM, Dag-Erling Smørgrav <des@FreeBSD.org> wrote:
>>
>> Devin Teske <dteske@freebsd.org> writes:
>>> If someone uses __STDC_VERSION_*_H__ to inject C23 syntax of their
>>> own, they are asking the advertisement to do visibility's job.  I may
>>> be missing a case where that is the right test; I have not found it in
>>> 7.1.2p6 yet.
>>
>> Imagine a single-header library (i.e. a big collection of static inline
>> functions) that uses __STDC_VERSION_FOO_H__ to choose between a C23
>> solution and a backward-compatible solution.  This header is then
>> included in a C99 program and fails because we are advertising C23
>> features to a C99 program.  It's really not that hard to understand.
>>
>>> Your predicate (__ISO_C_VISIBLE >= 2023 || __BSD_VISIBLE) would make
>>> the macros mean "this compilation can see C23 semantics from this
>>> header."  That is a policy we can talk about on its own.  I would
>>> rather not fold it into the _FOO_H_ restore, which was only POLA after
>>> gmp.
>>
>> I don't know what you mean with “fold it into the _FOO_H_ restore”.  The
>> “_FOO_H_ restore” has already happened and we're not going to rewrite
>> history.  I am asking for this feature to be implemented correctly.
>>
> 
> (combining my response to two people into one e-mail to limit branching of the thread)
> 
> DES,
> 
> You asked what I meant by "fold it into the _FOO_H_ restore," and you
> wrote that we are not going to rewrite history. I never meant that we
> would. A later commit can add the #if without touching 8d29d242; one
> can even reverse a change that way. I did not want the new #if on
> __STDC_VERSION_*_H__ handled together with putting the old
> _STDIO_H_-style names back for gmp.
> 
> DES and Warner,
> 
> stdio.h defines the macro before it includes cdefs.h. cdefs.h would
> come first; 77 other headers under /usr/include already test
> __BSD_VISIBLE. Then the #if as you both named:
> 
>     #include <sys/cdefs.h>
>     #if __ISO_C_VISIBLE >= 2023 || __BSD_VISIBLE
>     #define __STDC_VERSION_STDIO_H__	202311L
>     #endif
> 
> Same pattern on the other headers. If you both agree that is the
> approach, Faraz can put the Differential up.
> 
> Devin
> 

If __STDC_VERSION_STRING_H_, __STDC_VERSION_WCHAR_H__, or
__STDC_VERSION_STDLIB_H__ ever get such it looks like . . .


For:

    #if __ISO_C_VISIBLE >= 2023 || __BSD_VISIBLE
    #define __STDC_VERSION_STRING_H__	202311L
    #endif

It looks like __BSD_VISIBLE would need to imply that memchr, strchr,
strpbrk, strrchr, and strstr would have the new C23 Qualifier-Preserving
macro behavior.

For:

    #if __ISO_C_VISIBLE >= 2023 || __BSD_VISIBLE
    #define __STDC_VERSION_WCHAR_H__	202311L
    #endif

It looks like __BSD_VISIBLE would need to imply that wmemchr, wcschr,
wcspbrk, wcsrchr, and wcasstr would have the new C23
Qualifier-Preserving macro behavior.

For:

    #if __ISO_C_VISIBLE >= 2023 || __BSD_VISIBLE
    #define __STDC_VERSION_STDLIB_H__	202311L
    #endif

It looks like __BSD_VISIBLE would need to imply that bsearch and
bsearch_s would have the new C23 Qualifier-Preserving macro behavior.


(That includes the lack of such for (NAME) notation and function pointer
use.)

(I ignore here C++ contexts.)


-- 
===
Mark Millard
marklmi at yahoo.com