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

From: Devin Teske <dteske_at_freebsd.org>
Date: Tue, 25 Aug 2026 16:16:12 UTC

> On Aug 25, 2026, at 3:48 AM, Dag-Erling Smørgrav <des@FreeBSD.org> wrote:
> 
> Faraz Vahedi <kfv@FreeBSD.org> writes:
>> Since these macros solely advertise which revision of the header our
>> libc implements and are neither a language-mode nor visibility switch,
>> I believe we’re fine.  C23-only identifiers are already gated on our
>> visibility macros, and exposure of these feature test macros per se
>> are not of any harm, even for libraries targeting modes prior to C23.
>> For the same very reason, it is also fine to have these as include
>> guards (which brand new C23 headers like <stdbit.h> and <stdckdint.h>
>> still do).
>> 
>> My restoration of traditional guards was just to avoid any possible
>> POLA violation for those depending on them (albeit wrong) as reported
>> by dim for math/gmp port as an example.
> 
> Just because you don't understand why they did it doesn't mean it's
> wrong.  It just means you're young and inexperienced and have no
> business making categorical statements like the above.  Please make the
> __STDC_VERSION macros conditional on __ISO_C_VISIBLE >= 2023 ||
> __BSD_VISIBLE.
> 
> DES
> -- 
> Dag-Erling Smørgrav - des@FreeBSD.org
> 

Dag-Erling,

I looked at this because I wanted to understand the failure you
described rather than let it sit as a yes/no on the restore.

You wrote that a library might offer C23 extras predicated on
__STDC_VERSION_*, and that a C99 program using that library would
then fail to build because we define the macros unconditionally.  That
is a real problem if the macros are acting as a visibility
predicate.

The way I have been reading ISO/IEC 9899:2024, 7.1.2p6 [1] is that
they advertise which revision of the header our libc implements, so a
program can ask the library a question -std=c23 cannot answer.
Language mode is still __STDC_VERSION__ (6.10.10.2).  Our C23
identifiers are already predicated on __ISO_C_VISIBLE [2] — BOOL_MAX
and the rest — so a -std=c99 translation unit should not see those
identifiers either way.

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.

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.

If I have the split wrong, I would like to hear it.

Devin

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
[2] https://reviews.freebsd.org/D47576