__thread 上的夹板 barfs,它是 C99 的一部分
运行
matt@stanley:~/cpfs$ splint -paramuse +gnuextensions cpfs.c
夹板在这一行停止:
__thread int cpfs_errno;
出现解析错误:
cpfs.c:127:13: Parse Error: Non-function declaration: __thread : int. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue.
检查文档并漱口,但没有提及 __thread
。但是 __thread
是C99 规范的一部分,Splint 据称支持该规范(插入参考文献)。
这是怎么回事?如何让夹板识别__thread
?
Running splint
matt@stanley:~/cpfs$ splint -paramuse +gnuextensions cpfs.c
Halts on this line:
__thread int cpfs_errno;
With a parse error:
cpfs.c:127:13: Parse Error: Non-function declaration: __thread : int. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue.
Checking the documentation and gargle comes up with no mention of __thread
. However __thread
is part of the C99 spec, which Splint allegedly supports (insert reference).
What's going on here? How can I get splint to recognize __thread
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
__thread
不在 C99 中。它是一个 GNU C 扩展 - 您链接到的部分位于 C 语言家族的扩展。它描述了对 C99 标准的更改的扩展,大概是为了在未来的标准修订中采用它做准备。__thread
is not in C99. It is a GNU C extension - the section you have linked to is within Extensions to the C Language Family. It describes the extension in terms of changes to the C99 standard, presumably as preparation to have it adopted in a future revision of the standard.从 splint FAQ 中,只需将
-D__thread=
添加到夹板命令行。这将具有在 splint 检查代码时从代码中删除 __thread 关键字的效果。我在这里假设夹板不是特别线程感知的,并且无法使用通过关键字传达给 GCC 的信息。From the splint FAQ, just add
-D__thread=
to the splint command line. This will have the effect of removing the__thread
keyword from the code while splint is examining it. I'm assuming here that splint is not particularly thread aware, and wouldn't be able to use the information that was conveyed to GCC by the keyword.