Liste des Groupes | Revenir à cl c |
On 15.02.2025 18:29, Michael S wrote:On Fri, 14 Feb 2025 20:51:38 +0100
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:>
Actually, in the same code, I'm also using the strtok() function
strtok() is one of the relatively small set of more problemetic
functions in C library that are not thread-safe.
I know that it's not thread-safe. (You can't miss that information
if you look up the man page to inspect the function interface.)
If you only care about POSIX target, the I'd reccomend to avoid
strtok and to use strtok_r().
But since I don't use threads - neither here nor did I ever needed
them generally in my "C" contexts - that's unnecessary. Isn't it?
Moreover, I prefer functions with a simpler interface to functions
with a more clumsy one (I mean the 'char **saveptr' part); so why
use the complex one in the first place if it just complicates its
use and reduces the code clarity unnecessarily.
Re "more problematic functions in C library"...
I had to chuckle on that; if you're coming from other languages
most "C" functions - especially the low-level "C" functions that
operate on memory with pointers - don't look "unproblematic". :-)
Janis
Les messages affichés proviennent d'usenet.