编译器警告(等级 1)C4042

“identifier”:存储类不正确

指定的存储类不能用于此上下文中的此标识符。 编译器改用默认存储类:

  • extern,如果 identifier 是函数

  • auto,如果 identifier 是形参或局部变量

  • 不是存储类,如果 identifier 是全局变量

在参数声明中指定 register 以外的存储类可能导致此警告。

下面的示例生成 C4042

// C4042.cpp
// compile with: /W1 /LD
int func2( __declspec( thread ) int tls_i )    // C4042
// try the following line instead
// int func2( int tls_i )
{
   return tls_i;
}