नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'identifier' : dynamic initialization of 'thread' data not allowed in managed/WinRT code
Remarks
In managed or WinRT code, variables declared by using the __declspec(thread) storage class modifier attribute or the thread_local storage class specifier cannot be initialized with an expression that requires evaluation at run-time. A static expression is required to initialize __declspec(thread) or thread_local data in these runtime environments.
Example
The following example generates C2482 in managed (/clr) and in WinRT (/ZW) code:
// C2482.cpp
// For managed example, compile with: cl /EHsc /c /clr C2482.cpp
// For WinRT example, compile with: cl /EHsc /c /ZW C2482.cpp
#define Thread __declspec( thread )
Thread int tls_i1 = tls_i1; // C2482
int j = j; // OK in C++; C error
Thread int tls_i2 = sizeof( tls_i2 ); // Okay in C and C++
To fix this issue, initialize thread-local storage by using a constant, constexpr, or static expression. Perform any thread-specific initialization separately.