tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Some rambling about strdup()'s standard and other standards issues
Greg A. Woods wrote:
>
> [strdup]
> In any case the OpenGroup "Issue 6" spec definitely has strdup(), and it
> refers to "IEEE Std 1003.1-2001" as the origin of this definition.
> However they say it was moved from being an _XOPEN_SOURCE extension
> "first released in Issue 4, Version 2", and "Moved to BASE" in the
> previous version, "Issue 5".
>
> https://pubs.opengroup.org/onlinepubs/007904975/functions/strdup.html
>
> Hmmm....
It is marked as part of the "XSI option", this means that "_XOPEN_SOURCE"
must be defined (to 600 for SUSv3, but it was already defined in SUSv2,
this means 500 would be sufficient).
Since POSIX.1-2008 (Issue 7) it is available via "_POSIX_C_SOURCE"
(defined to at least 200809L).
See POSIX.1-2024 (Issue 8) says:
<https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/V2_chap02.html#tag_16_02>
Mixing _XOPEN_SOURCE and _POSIX_C_SOURCE in the wrong way can be
undefined behaviour.
snprintf() comes to mind, which has different semantics in SUSv2
and POSIX.1-2001).
POSIX.1-2024 is based on C17:
<https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/c17.html>
C23 is required to get strdup() without POSIX extensions.
> In the current edition, "Issue 8", aka "IEEE Std 1003.1-2024 Edition"
> there is a change history section, but it seems self-contradictory:
>
> https://pubs.opengroup.org/onlinepubs/9699919799/
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/strdup.html
>
> How can it be "moved to [the] base" twice? (Once in OpenGroup and once
> in the source IEEE docs?)
Maybe imported from the separate X/OPEN standard into POSIX (as XSI option)
with Issue 5. And now available without XSI option since Issue 7.
Home |
Main Index |
Thread Index |
Old Index