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

Simon Barth <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <aR1PQxH01Jhqwq52@jamespb-arch>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.