内联函数 [英] inline functions
问题描述
让我们说我有一个功能
func()
{
.. ..........
func();
..........
}
即它是一个递归函数。如果我将其声明为内联会发生什么
Let''s say I have a function
func()
{
............
func();
..........
}
I.e it is a recursive function. What happens if I declare it inline
推荐答案
在2006-02-07,Aloo< an ******* *****@rediffmail.com>写道:
On 2006-02-07, Aloo <an************@rediffmail.com> wrote:
让我们说我有一个功能
func()
{
....... ....
func();
.........
}
即它是一个递归函数。如果我将其声明为内联会发生什么?
Let''s say I have a function
func()
{
...........
func();
.........
}
I.e it is a recursive function. What happens if I declare it inline
它不会被内联,或者它只会被内联一定数量的
次。
没有_requirement_编译器在任何给定函数调用的地方插入内联代码。
It won''t be inlined, or it will only be inlined a certain number of
times.
There is no _requirement_ that the compiler insert inline code at any
given place the function is called.
Aloo写道:
让我们说我有一个功能
func()
。 ...........
func();
..........
}
即它是一个递归函数。如果我内联声明会发生什么
Let''s say I have a function
func()
{
............
func();
..........
}
I.e it is a recursive function. What happens if I declare it inline
inline更多的是提示而不是指令,编译器可以自由地
忽略''inline''它认为内联是不合适的。这个
将是其中一个案例。
-
Ian Collins。
inline is more of a hint than an instruction, the compiler is at liberty
to ignore ''inline'' where it considers inline to be inappropriate. This
would be one of those cases.
--
Ian Collins.
Aloo写道:
让我们说我有[递归]函数。
如果我将其声明为内联会发生什么
Let''s say I have a [recursive] function.
What happens if I declare it inline
inline只是对编译器的一个提示,它可能会被忽略。
相关说明,优秀的优化编译器可以消除一些
递归形式。
inline is merely a hint to the compiler, and it may be ignored.
On a related note, good optimizing compilers can eliminate some
forms of recursion.
这篇关于内联函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!