c - 无法理解以下函数声明

标签 c linux function linux-device-driver gcc-extensions

任何人都可以解释以下函数声明吗?

inline uint64_t MY_FUNC(unsigned long param) __attribute__ ((pure, always_inline)); 

最佳答案

always_inlinepuregcc 函数属性。来自海湾合作委员会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/

相关文章:

bash - ZSH:在脚本文件中执行函数

javascript - JavaScript 中的全局用户定义函数列表?

c - 已编译编译器对已编译代码的性能

linux - Linux 内核的哪一部分强制执行权限分离以及如何执行?

linux - 将 nl 命令中的行增量设置为 float

linux - cURL 设置最大文件大小

Python - 字典比较

c - 实现简单的多线程程序的基本信号量

c++ - 这个 makefile 是如何生成目标文件的?

c - C函数打印错误