[PATCH v2 1/2] libc: Make string.h POSIX.1-2024 compliant

John Scott jscott@posteo.net
Sun Nov 16 03:46:34 GMT 2025


Simon Barth wrote:
> POSIX.1-2024 added strlcpy, strlcat, and memmem to strings.h. Previously these functions were only available as parts of BSD or GNU extensions.
> Fix the header so that the symbol are visible for either the right extensions, or for POSIX.1-2024.

This is a pedantic comment, but technically these functions do not have to be guarded behind feature test macros at all. Functions beginning with 'str' or 'mem' in <string.h> are in implementation-reserved namespace. I believe this provision goes back to C89.
You can see it in a C17 draft at https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#nameddest=subsection.7.31.13
POSIX has always done the same: https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_02_02

As an example, POSIX provides that Annex K's string functions need not be guarded behind the __STDC_WANT_LIB_EXT1__ feature test macro.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <https://sourceware.org/pipermail/newlib/attachments/20251116/41689675/attachment.sig>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6270 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20251116/41689675/attachment.p7s>


More information about the Newlib mailing list