What is difference between inline function and ordinary function?

Showing Answers 1 - 21 of 21 Answers

Lei

  • Mar 4th, 2007
 

The difference between an inline and a regular function is that instead of calling the function, the compiler copies the function on the spot.

Inline functions are just like normal functions except that they are preceded by the keyword inline!! wherever the compiler finds the call for that function it puts the code for that function dere!! the functions are defined as inline when the function is small and is called many times.

  Was this answer useful?  Yes

Pingu

  • Mar 8th, 2007
 

The keyword inline is just a request to compiler. If the function is really big, compiler may not copy the whole code and may treat it as an ordinary function.

  Was this answer useful?  Yes

saurabh08_chd

  • Mar 13th, 2007
 

each time there's is a function call in the source file , the actual code from function is inserted , instead of a jump to the function.

  Was this answer useful?  Yes

sandeep chahal

  • Mar 14th, 2007
 

the ordinary function do a lot of activity store the argument into stack,saving register
control goes to the function and return value to the calling function ,but in inline
function body replace to the calling the function (like as macro expansion)
it is reqest  to the compiler not a command,compiler may ignore the request if
function is so length

  Was this answer useful?  Yes

wow_suraj

  • May 2nd, 2008
 

In case of ordinary function, when calling the function the scope jumps to the function and after return jumps back to the function call statement resulting in some extra execution time. While in case of inline function the scope doesn't really jumps to the function saving some execution time. However, while making any function inline we are just sending request to make the function inline, it completely depends on the compiler that it will treat the function as inline or some ordinary function.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions