[PATCH v2 1/2] libc: Make string.h POSIX.1-2024 compliant
Simon Barth
Simon.Barth@gmx.de
Wed Nov 19 05:01:55 GMT 2025
Hi,
On Sun, Nov 16, 2025 at 03:46:34AM +0000, John Scott wrote:
> 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.
I understand that according to this, an implementation of the C library
is free to add functions with any of the prefixes 'str' or 'mem' to
<string.h>.
Are you proposing to _unguard_ all functions in <string.h>
that match those criteria?
Cheers,
Simon
More information about the Newlib
mailing list