correct me if I am wrong.
Standard C++, the topic of this newsgroup, has nothing to say about
threading and therefore nothing to say about the thread safety or otherwise
of standard functions. You need to ask this question in a newsgroup that
concerns itself with your specific C++ implementation.
NeilB
No.
More specifically, the ISO/ANSI standards that define the C and C++
programming languages do not require, or even recommend, that the standard
C/C++ libraries be "thread safe" (whatever that may mean for a given
execution environment).
HOWEVER: Software vendors often add their own thread safety support to
various components in the standard C/C++ libraries. So if you want to find
out whether a given feature/component in a particular implementation of the
"standard" C/C++ library is thread safe (and if so, to what degree it is
thread safe), you'll need to read the documentation that the vendor
presumably supplied with the standard library you are using. Also, many
software vendors have their own public newsgroups / mailing lists where the
users of that vendor's software products (e.g., a particualr vendor's C/C++
library) can ask questions about the vendor's software products. [n.b.
Platform- and vendor-specific HOWTOs are beyond the scope of the C/C++
language groups on Usenet (ref: see the FAQ docs for those groups).]
Jim
Henry Zhang wrote:
>
> I tried to add a critical section to write attemps to my files. However, I
> found it is as if unecessary...
> the fprintf is already thread-safe?
Be careful w.r.t. the implied meaning of "thread-safe" term.
On any POSIX (or SUS; even better) compliant impl. (standard
extension to ANSI C), it IS thread-safe... however, I guess,
you should really read this (especially the 1st link ;-)):
http://www.opengroup.org/onlinepubs/007904975/functions/flockfile.html
http://www.opengroup.org/onlinepubs/007904975/functions/fprintf.html
("Characters generated by fprintf() and printf() are printed as if
fputc() had been called.")
http://www.opengroup.org/onlinepubs/007904975/functions/fputc.html
http://www.opengroup.org/onlinepubs/007904975/functions/putc.html
http://www.opengroup.org/onlinepubs/007904975/functions/putc_unlocked.html
> correct me if I am wrong.
Uhmm. To me: NOT clear yet! ;-)
regards,
alexander.