c++ - GCC 编译器内联的深度

标签 c++ optimization gcc inline-functions

我研究过

The inline specifier is a hint to the compiler that it should attempt to generate code [...] inline rather than laying down the code for the function once and then calling through the usual function call mechanism.

问题:

  1. 如果 GCC 编译器的优化关闭,内联说明符是否被忽略?
  2. 当递归调用内联函数时,哪个编译器选项决定“内联深度”,直到它遵循正常的函数调用机制?
  3. 如果在 for 循环内调用内联函数,是否会出现相同的“内联深度”?

最佳答案

If optimization is turned off for the GCC compiler, is the inline specifier ignored?

是的,如果在 GCC 中关闭优化,则不会内联任何函数。它相当于在编译期间使用 -fno-inline 标志。看这个link

-fno-inline

不要注意 inline 关键字。通常此选项用于防止编译器扩展任何内联函数。请注意,如果您不进行优化,则无法内联扩展任何函数。

When inline functions are called recursively, which compiler option determines the 'depth of inlining', until it follows the normal function call mechanism ?

选项 max-inline-recursive-depthmax-inline-recursive-depth-auto。默认深度为 8。

关于c++ - GCC 编译器内联的深度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11175439/

相关文章:

c++ - 使用用户输入停止倒数计时器

c++ - C++中的分号是什么?

haskell - 检查 Haskell 中的空列表 : Is (length list == 0) or (list == []) more efficient?

c++ - 使用 gcc/g++/gdb/valgrind 调试时的魔数(Magic Number)?

Bash:如何将一个子命令生成的多个结果提供给一个命令

c++ - 静态和动态库

c++ - 如何使 Opencv SVM 更快?

c - 质数算法

Python搜索大列表速度

c - 为什么 fopen ("any_path_name",'r' ) 不返回 NULL?