That is what’s the scope of sharing static members?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes,
staticstorage duration implies that the variable in question comes into existence when the process is started and is deallocated not before the end of the process. It is shared by all threads of the process, and accessing it can cause data races between the threads, just like with a global variable.C++11 introduced a new storage duration specifier
thread_local, the use of which implies that there is one instance of the variable in each individual thread. It is allocated when the thread begins.Unfortunately none of the major compilers (GCC, Clang, VC++) has implemented this fully yet.