Liste des Groupes | Revenir à cl c |
Meanwhile, saw someone in another group write:strdup() and strndup() are being added to the C23 standard.
>
char * something;
something = strdup("writable string etc.");
if( something == NULL ) { etc. }
>
But that won't work if --std=c99, does work for g99 and c2x.
The (Linux) man page says:
/* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
>
I asked Google about it being a POSIX extension
added at that late date, and it gave me an answer
about the C standard:
>
"C9X London meeting update"
https://groups.google.com/g/comp.std.c/c/pMaEU_8Rb7w
_ _ _ _ _
2. strsep and strdup are not being added. strsep() is out because
not enough people wanted it to vote it in; strdup() lost on the
grounds that it would be the *ONLY* function other than *alloc()
in the entire library whose return could be sanely passed to free(),
and this is surprising.
_ _ _ _ _
>
Also: <https://stackoverflow.com/questions/32944390/what-is-the-rationale-
for-not-including-strdup-in-the-c-standard>
>
Anyway, pointed out that they can just use an initializer, something
about which I was clued in by a friendly person in this very group.
Les messages affichés proviennent d'usenet.