Wie initialisiere ich eine lokale Thread-Variable in C ++? [Duplikat]
Mögliche Duplikate:
C ++ 11 thread_local in gcc - Alternativen
Gibt es eine Möglichkeit, thread_local mit GCCs __thread vollständig zu emulieren?
Ich wollte das C ++ 11 verwendenthread_local
um eine thread_local-Variable zu erstellen und zu verwenden, aber da sie noch nicht von gcc unterstützt wird, verwende ich gcc specific__thread
. Die Art, wie ich die Variable deklariert habe, ist
myClass
{
public:
static __thread int64_t m_minInt;
};
__thread int64_t myClass::m_minInt = 100;
Wenn ich es kompiliere, erhalte ich eine Fehlermeldung wie
error: ‘myClass::minInt’ is thread-local and so cannot be dynamically initialized
Wie man es richtig macht?
PS: gcc version: 4.6.3