是“线程存储持续时间”和“线程本地存储持续时间”同义词?
C11,6.2.4对象的存储持续时间,4(添加了重点):
用存储级规范符声明标识符的对象
_thread_local
具有线程存储持续时间。
C11,7.5错误< errno.h> 2(添加了强调):
errno
扩展到可修改的lvalue 201),该201)具有int
和
是“线程存储持续时间”和“线程本地存储持续时间”同义词?
额外注意:当前的支持 _thread_local
独立于 __ stdc_no_threads __
,而它是(可能)预计将取决于。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我看到的唯一合理的解释,是的。规范第6.2.4/1段中存储持续时间的定义不包括“线程本地存储持续时间”:
但是,线程存储持续时间是用
_thread_local
存储类规范声明的标识符的存储持续时间,在一般讨论中,描述与“线程local local”相关的对象相关的对象。在第7.5节中,我出现了“线程本地存储持续时间”(这是规格中该术语的唯一出现)构成编辑错误,但我认为预期的含义并不疑问。规格的说法强化了这一点(C11 7.5/3)。
errno
在不同线程中可能具有不同的值可以通过两种方式解释:errno
具有线程存储持续时间,或者errno的特殊,独特的特征
,除了具有线程存储持续时间以外的其他方式提供。我发现(2)鉴于规格的整体,完全令人难以置信。
That's the only plausible interpretation I see, yes. The definition of storage duration in paragraph 6.2.4/1 of the spec does not include a "thread local storage duration":
However, thread storage duration is the storage duration of identifiers declared with the
_Thread_local
storage class specifier, and it is fairly common in general discussion to describe the objects associated with such identifiers as "thread local". I take the appearance of "thread local storage duration" in in section 7.5 -- which is the only appearance of that term in the spec -- to constitute an editorial error, but I don't think the intended meaning is in doubt. This is reinforced by the spec's remarks that(C11 7.5/3).
That
errno
may have different values in different threads can be explained in only two ways:errno
has thread storage duration, ORerrno
, provided by some means other than it having thread storage duration.I find explanation (2) altogether implausible in light of the spec overall.
是的。他们是同一件事。
C11库文件的规范
errno.h
告诉您,errno
的行为应为:声明为:存储持续时间规范告诉您什么
_thread_local < /代码>表示
Yes. They are the same thing.
The specification for the C11 library file
errno.h
is telling you thaterrno
shall behave as if declared as:and the storage duration specification is telling you what
_Thread_local
means