Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: standard error messages in a std::string or in a const char * Date: Wed, 11 Sep 2019 02:37:31 -0700 Organization: None to speak of Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="147e9b61f94efc0a5a29840b1fadf056"; logging-data="14287"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Kofgh/gWTSfOVzOKe8/nS" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ra453AygeoObJ9x8VAdfuHSSuek= sha1:oTqq7xBASc7Vr4sq/RU9pueWpcE= Xref: csiph.com comp.lang.c++:68309 Juha Nieminen writes: > Jorgen Grahn wrote: >>> https://linux.die.net/man/3/strerror >>> >>> maybe will work ... >> >> It will do what the documentation says, and lots of people use it. >> Note its limitations, though. It's not thread-safe, for example. > > What do you mean it's not thread-safe? AFAIK errno is thread-local > according to the standard. errno is thread-local. That doesn't necessarily mean that strerror() is thread-safe. For example, a conforming implementation could always return a pointer to the same static buffer, initialized with the appropriate message before it returns. And at least one implementation (x86_64-w64-mingw32-gcc) appears to do exactly that. N1570 7.24.6.2p3: The strerror function is not required to avoid data races with other calls to the strerror function. The implementation shall behave as if no library function calls the strerror function. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */