我可以部分/选择性地内联函数吗?

标签 c inline c99

void run_hot(void) {
    // I am called very often!
    serve();
    // <more code here>
}

void run_cold(void) {
    // I am called only occasionally!
    serve();
    // <more code here>
}

???inline??? void serve(void) {
    // I only want to be called inline from hot functions!
    // <more code here>
}

有什么方法可以显式地在函数 B 中内联函数 A 而在函数 not 中显式地内联相同的函数 A < em>C?还是我完全受制于我的编译器?

最佳答案

你完全受制于内联编译器的摆布。
撇开部分不谈,是否内联一个函数完全是编译器做出的最佳决定,您应该依靠它来做出最佳决定。

关于我可以部分/选择性地内联函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10326792/

相关文章:

c - 为什么用 += 添加到指针有效,而指针 + 1 无效?

c++ - 错误修复。 OpenGL、GLSL Sprite 网格渲染问题

c - gcc 无法在没有 -O2 的情况下内联函数

c - 当用类型声明指针时,这怎么能取消引用 ‘void *’ 呢?

c - ctime 是否返回公历日期?

c - C99中 "arithmetic operation"的定义是什么?

c - 将多个值返回给多个变量

c - 使用 C 从路由器转储闪存

javascript - 与顺风动态内联更改类属性

linux - 管道文件的 Bash 内联版本到 bluetoothctl