“identifier”:“thread”只对静态作用域的数据项有效
不能将 thread
属性与自动变量、非静态数据成员、函数参数或函数声明或定义一起使用。
仅对全局变量、静态数据成员和局部静态变量使用 thread
属性。
以下示例生成 C2480:
// C2480.cpp
// compile with: /c
__declspec( thread ) void func(); // C2480
__declspec( thread ) static int i; // OK