__attribute __((force))的作用是什么? [英] What does the __attribute__((force)) do?
问题描述
听起来我应该可以使用Google,但找不到很好的参考. __attribute__((force))
到底是做什么的?如:
return (__attribute__((force)) uint32_t) *p
(这是针对使用clang交叉编译的ARM系统,但是即使在clang/arm特定页面中,我也找不到此属性的任何引用.)
__attribute__((force))
用于抑制稀疏(Linux内核的c语义检查器)中的警告.
稀疏的维基百科文章列出了稀疏定义的以下属性:>
- address_space(num)
- 按位
- 力
- 上下文(表达式,in_context,out_context)
如果需要有关这些的更多信息,可以查看 sparse的手册页
在Linux内核中,某些属性在中重新定义linux/include/linux/compiler_types.h .例如,__force
扩展为__attribute__((force))
或__bitwise
扩展为__attribute__((bitwise))
.
但是关于稀疏的Linux文档告诉我们,gcc会忽略以下属性:
使用gcc,所有"__按位"/"__ 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屋!