コンパイラ エラー C2384
'member' : __declspec(thread) をマネージド クラスまたは WinRT クラスのメンバーに適用できません
スレッド修飾子 は、Runtime クラスのマネージド または Windowsメンバーでは使用できません。
マネージド コード内の静的スレッド ローカル ストレージは、プロセスの開始時に DLL を静的に読み込む必要がある DLL にのみ — 使用できます。 Windows ランタイムでは、スレッド ローカル ストレージはサポートされません。
次の例では、C2384 を生成し、C++/CLI コードで修正する方法を示しています。
// C2384.cpp
// compile with: /clr /c
public ref class B {
public:
__declspec( thread ) static int tls_i = 1; // C2384
// OK - declare with attribute instead
[System::ThreadStaticAttribute]
static int tls_j;
};