572 Subj : Re: Can C++ local static objects be made thread safe? To : comp.programming.threads From : Gianni Mariani Date : Sun Feb 06 2005 10:57 pm Giancarlo Niccolai wrote: > Gianni Mariani wrote: .... >>I'd like to know the C++ experts you're talking about. > > > nntp://comp.lang.c++ > http://www.parashift.com/c++-faq-lite/ > > And especially > http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.11 > > and the followings. The proposal that you point to does not work unless the compiler supports thread safe local static initialization or you perform the locking yourself like I proposed earlier in this thread. .... > Ah, BTW: EVERY compiler allows you to specify the exact order of static > initializers with PRAGMA directive; so, you don't really have the problem > you think you have, because, if your program badly depends on things done > before others during static initialization, you can just tell the compiler > "ok, do this before than that plz."... Since if you need that it means that > you have bad code, a #pragma or two won't make it worse. And is this portable ? It sounds like a maintenance nightmare. Also, the idea that you call every method that has a static local in main (before any threads are started) is very difficult when you use templates since it's impossible to know just how many of them exist. . 0