任何人都可以解释以下函数声明吗?
inline uint64_t MY_FUNC(unsigned long param) __attribute__ ((pure, always_inline));
最佳答案
always_inline
和 pure
是 gcc
函数属性。来自海湾合作委员会documentation :
always_inline
Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function independent of any restrictions that otherwise apply to inlining. Failure to inline such a function is diagnosed as an error. Note that if such a function is called indirectly the compiler may or may not inline it depending on optimization level and a failure to inline an indirect call may or may not be diagnosed.
您的MY_FUNC
函数已经具有inline
函数说明符,但在C中inline
只是内联的建议,编译器没有义务内联函数。
pure
Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure.
关于c - 无法理解以下函数声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27566928/