编译器错误 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

另请参阅

thread