[PATCH] Add feature test macros for POSIX.1-2024.

Collin Funk collin.funk1@gmail.com
Wed Nov 5 02:11:39 GMT 2025


Carlos O'Donell <carlos@redhat.com> writes:

> On 5/23/25 12:00 AM, Collin Funk wrote:
>> * include/features.h (_POSIX_C_SOURCE): Document the value of 202405L
>> for POSIX.1-2024.  Set it to 202405L when _GNU_SOURCE or _DEFAULT_SOURCE
>> is defined.
>> (_XOPEN_SOURCE): Document the value of 800 for POSIX-1.2024.  Set it to
>> 800 when _GNU_SOURCE is defined.
>> (__USE_XOPEN2K24, __USE_XOPEN2K24XSI): New internal macros.  Set them
>> when _POSIX_C_SOURCE is 202405L or greater and/or when _XOPEN_SOURCE is
>> 800 or greater.
>> * manual/creature.texi (Feature Test Macros): Document the new values
>> for _POSIX_C_SOURCE and _XOPEN_SOURCE.
>> Signed-off-by: Collin Funk <collin.funk1@gmail.com>
>
> The new __USE_XOPEN2K24 should eventually be used in unistd.h to set
> _POSIX_VERSION, and _POSIX2_VERSION in unistd.h when we finish the
> implementation of the new standard and wish to indicate conformance.
>
> I expect you did not change unistd.h because you don't think we're
> conforming yet or haven't done the work to verify? I'm not ask for
> that work to be done, just checking. The work to verify conformance
> is more than the work to add these checks here for when the user
> requests a given version and the system headers are altered to
> include or remove those features. This change being the first step
> towards conditionalizing the headers.

My goal was to do each header individually, since that felt a bit more
friendly to reviewers as opposed to one large patch. Therefore, this one
was really just a prerequisite to that.

The conform checks are a bit of a chore for C23 and POSIX.1-2024 since
some of the things depend on GCC and/or architecture. See some Joseph's
responses to one of my initial patches [1]. Also GCC 12.1 supports
-std=c2x and -std=gnu2x not -std=c23 and -std=gnu23. So I am thinking
there might be some problems because of that.

> Please push. No NEWS entry required since we don't have anything really
> news-worth yet for new features.

Thanks, done.

Collin

[1] https://inbox.sourceware.org/libc-alpha/fc312bc5-56b2-e9ee-6e89-476d02d91687@redhat.com/


More information about the Libc-alpha mailing list