c++ - thread_local "storage class specified"

标签 c++ multithreading thread-local

<分区>

我在我的 C++ 类 thread_local unsigned int counter_ = 0; 的私有(private)部分声明了一个 thread_local 并且我一直收到错误“为 counter_ 指定的存储类”

最佳答案

来自 C++ 17 标准 *12.2 类成员)

9 A member shall not be declared with the extern storage-class-specifier. Within a class definition, a member shall not be declared with the thread_local storage-class-specifier unless also declared static.

关于c++ - thread_local "storage class specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59275011/

相关文章:

java - 如何使 JNI RegisterNatives callack Java 函数具有 C++ 实例范围?

c++ - 使用 rdbuf 将文件内容复制到缓冲区失败

Android 游戏循环 - 线程还是处理程序?

java - Joda-Time : convert SimpleDateFormat pattern to DateTimeFormat. forPattern

java threadlocal 单例 - 它是什么?

c++ - 在类定义中动态分配内存有什么影响?

c++ - 将 pfx 证书转换为 PEM 格式

c++ - 在 QueueUserAPC 中指定的回调未被调用

Java多线程和迭代器,应该很简单,初学者

java - 测试 ThreadLocal 成员变量