重複の可能性:
gccのC ++ 11 thread_local-代替案
GCCの__threadを使用してthread_localを完全にエミュレートする方法はありますか?
c ++ 11thread_local
を使用してthread_local変数を作成して使用したかったのですが、gccでまだサポートされていないため、gcc固有のを使用しています__thread
。私が変数を宣言した方法は
myClass
{
public:
static __thread int64_t m_minInt;
};
__thread int64_t myClass::m_minInt = 100;
コンパイルすると、次のようなエラーが発生します
error: ‘myClass::minInt’ is thread-local and so cannot be dynamically initialized
適切にそれを行う方法は?
PS:gccバージョン:4.6.3