編譯器錯誤 C2483
'identifier' :具有建構函式或解構函式的對象無法宣告為 'thread'
在 Visual Studio 2015 和更新版本中,此錯誤訊息已經過時。 在舊版中,使用 屬性宣告的 thread
變數無法使用建構函式或其他需要運行時間評估的表達式初始化。 需要靜態表達式才能初始化 thread
數據。
範例
下列範例會在 Visual Studio 2013 和舊版中產生 C2483。
// C2483.cpp
// compile with: /c
__declspec(thread) struct A {
A(){}
~A(){}
} aa; // C2483 error
__declspec(thread) struct B {} b; // OK