Compiler Error C2482
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2482.
identifier' : dynamic initialization of 'thread' data not allowed
Variables declared with the thread attribute cannot be initialized with an expression that requires run-time evaluation. A static expression is required to initialize thread data.
The following sample generates C2482:
// C2482.cpp // compile with: /c #define Thread __declspec( thread ) Thread int tls_i = tls_i; // C2482 int j = j; // OK in C++; C error Thread int tls_i = sizeof( tls_i ); // Okay in C and C++
Show: