Why does OSX document atoi/atof as not being threadsafe?

Posted by Larry Gritz on Stack Overflow See other posts from Stack Overflow or by Larry Gritz
Published on 2011-01-07T23:43:43Z Indexed on 2011/01/08 4:53 UTC
Read the original article Hit count: 199

Filed under:
|

I understand that strtol and strtof are preferred to atoi/atof, since the former detect errors, and also strtol is much more flexible than atoi when it comes to non-base-10.

But I'm still curious about something: 'man atoi' (or atof) on OS X (though not on Linux!) mentions that atoi/atof are not threadsafe. I frankly have a hard time imagining a possible implementation of atoi or atof that would not be threadsafe. Does anybody know why the man page says this? Are these functions actually unsafe on OS X or any other platform? And if they are, why on earth wouldn't the library just define atoi in terms of strtol, and therefore be safe?

© Stack Overflow or respective owner

Related posts about c

    Related posts about osx