0

我正在使用 C 语言开发一个项目。编译时出现此错误:

warning: inlining failed in call to 'xyz()'  --param max-inline-insns-single limit reached

我的编译器将警告报告为错误,我不想绕过它。

那么,这是因为内联函数的嵌套过多吗?我可以做些什么来使它工作(除了不声明内联函数)?

谢谢!

4

2 回答 2

4

正如gcc 文档指出的那样:

最大内联-insns-单:

几个参数控制 gcc 中使用的树内联。此数字设置树内联器将考虑内联的单个函数中的最大指令数(在 GCC 的内部表示中计算)。这仅影响内联声明的函数和在类声明 (C++) 中实现的方法。默认值为 500。

如果您仍然希望将警告视为错误(不是不合理的愿望),只需使用:

--param max-inline-insns-single=1000

(或更大的价值)将其从默认值提升。

于 2013-07-03T02:07:44.343 回答
0

gcc/g++ 提供选项来调整inliner.

-finline-limit=n
By default, GCC limits the size of functions that can be inlined. This flag allows the control of this limit for functions that are explicitly marked as inline (i.e., marked with the inline keyword or defined within the class definition in c++). n is the size of functions that can be inlined in number of pseudo instructions (not counting parameter handling). The default value of n is 600. Increasing this value can result in more inlined code at the cost of compilation time and memory consumption. Decreasing usually makes the compilation faster and less code will be inlined (which presumably means slower programs). This option is particularly useful for programs that use inlining heavily such as those based on recursive templates with C++.
Inlining is actually controlled by a number of parameters, which may be specified individually by using --param name=value. The -finline-limit=n option sets some of these parameters as follows:

max-inline-insns-single
is set to n/2. 
max-inline-insns-auto
is set to n/2. 
min-inline-insns
is set to 130 or n/4, whichever is smaller. 
max-inline-insns-rtl
is set to n.

所以你能做的就是增加n. 尽管手动进行内联不是一个好主意(编译器在这方面非常擅长)。

在此处阅读更多信息或man gcc

于 2013-07-03T02:13:09.297 回答