Possible Duplicate:
C++11 thread_local in gcc - alternatives
Is there any way to fully emulate thread_local using GCC's __thread?
I wanted to use the c++11 thread_local
to create and use thread_local variable but as it is not yet supported by gcc, I am using gcc specific __thread
. The way I declared the variable is
myClass
{
public:
static __thread int64_t m_minInt;
};
__thread int64_t myClass::m_minInt = 100;
When I compile it, I get an error like
error: ‘myClass::minInt’ is thread-local and so cannot be dynamically initialized
How to properly do it?
PS: gcc version: 4.6.3