Skip to content

Commit 38da587

Browse files
author
Colin Robertson
committed
Add sentence about fixes.
1 parent b982fb2 commit 38da587

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/error-messages/compiler-errors-1/compiler-error-c2482.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ms.workload: ["cplusplus"]
1818
1919
## Remarks
2020

21-
In managed or WinRT code, variables declared by using the [__declspec(thread)](../../cpp/thread.md) storage class modifier attribute or the [thread_local](../../cpp/storage-classes-cpp.md#thread_local) storage class specifier cannot be initialized with an expression that requires run-time evaluation. A static expression is required to initialize `__declspec(thread)` or `thread_local` data in these runtime environments.
21+
In managed or WinRT code, variables declared by using the [__declspec(thread)](../../cpp/thread.md) storage class modifier attribute or the [thread_local](../../cpp/storage-classes-cpp.md#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.
2222

2323
## Example
2424

@@ -34,3 +34,5 @@ Thread int tls_i1 = tls_i1; // C2482
3434
int j = j; // OK in C++; C error
3535
Thread int tls_i2 = sizeof( tls_i2 ); // Okay in C and C++
3636
```
37+
38+
To fix this issue, initialize thread-local storage by using a constant, **constexpr**, or static expression. Perform any thread-specific initialization separately.

0 commit comments

Comments
 (0)