【发布时间】:2020-04-04 02:22:44
【问题描述】:
我在我的 C++ 类 thread_local unsigned int counter_ = 0; 的私有部分声明了一个 thread_local,但我不断收到错误“为 counter_ 指定的存储类”
【问题讨论】:
标签: c++ multithreading thread-local
我在我的 C++ 类 thread_local unsigned int counter_ = 0; 的私有部分声明了一个 thread_local,但我不断收到错误“为 counter_ 指定的存储类”
【问题讨论】:
标签: c++ multithreading thread-local
来自 C++ 17 标准 *12.2 类成员)
9 成员不能用 extern 声明 存储类说明符。在类定义中,成员不得 使用 thread_local 存储类说明符声明,除非也 声明为静态的。
【讨论】: