__attribute__((force)) 有什么作用? [英] What does the __attribute__((force)) do?
问题描述
这听起来像我应该可以谷歌的东西,但我找不到很好的参考.__attribute__((force))
到底做了什么?如:
return (__attribute__((force)) uint32_t) *p
(这是针对 ARM 系统的,与 clang 交叉编译,但即使在 clang/arm 特定页面中,我也无法在此属性的任何地方找到任何引用..).
__attribute__((force))
用于抑制 sparse 中的警告,Linux 内核的 c 语义检查器.
维基百科文章的稀疏性列出了以下由 sparse 定义的属性:>
- address_space(num)
- 按位
- 强制
- 上下文(表达式,输入上下文,输出上下文)
如果你需要更多关于这些的信息,你可以看看sparse的手册页
在 linux 内核中,一些这些属性在 中重新定义linux/include/linux/compiler_types.h.例如 __force
扩展为 __attribute__((force))
或 __bitwise
到 __attribute__((bitwise))
.
但是 linux 文档关于稀疏告诉我们,gcc 忽略了这些属性:
<块引用>使用 gcc,所有__bitwise"/__force 东西"都消失了,最终看起来就像 gcc 的整数一样.
This sounds like something I should be able to Google, but I can't find a good reference. What exactly does __attribute__((force))
do? As in:
return (__attribute__((force)) uint32_t) *p
(this is for an ARM system, cross compiled with clang, but I can't find any reference anywhere on this attribute even in clang/arm specific pages..).
__attribute__((force))
is used to suppress warnings in sparse, the c semantics checker of the linux kernel.
The wikipedia article of sparse lists the following attributes as defined by sparse:
- address_space(num)
- bitwise
- force
- context(expression,in_context,out_context)
If you need more information about these, you can take a look at the man page of sparse
In the linux kernel some these attributes are redefined in linux/include/linux/compiler_types.h. For example __force
expands to __attribute__((force))
or __bitwise
to __attribute__((bitwise))
.
However the linux documentation about sparse tells us, that gcc ignores these attributes:
And with gcc, all the "__bitwise"/"__force stuff" goes away, and it all ends up looking just like integers to gcc.
这篇关于__attribute__((force)) 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!