what is inline function?

Answer Posted / anoop raj

The point of making a function inline is to hint to the
compiler that it is worth making some form of extra effort
to call the function faster than it would otherwise -
generally by substituting the code of the function into its
caller. As well as eliminating the need for a call and
return sequence, it might allow the compiler to perform
certain optimizations between the bodies of both functions.

Sometimes it is necessary for the compiler to emit a
stand-alone copy of the object code for a function even
though it is an inline function - for instance if it is
necessary to take the address of the function, or if it
can't be inlined in some particular context, or (perhaps) if
optimization has been turned off. (And of course, if you use
a compiler that doesn't understand inline, you'll need a
stand-alone copy of the object code so that all the calls
actually work at all.)

There are various ways to define inline functions; any given
kind of definition might definitely emit stand-alone object
code, definitely not emit stand-alone object code, or only
emit stand-alone object code if it is known to be needed.
Sometimes this can lead to duplication of object code, which
is a potential problem for following reasons:

1. It wastes space.
2. It can cause pointers to what is apparently the same
function to compare not equal to one another.
3. It might reduce the effectiveness of the instruction
cache. (Although in lining might do that in other ways too.)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is function what are the types of function?

563


Explain what are the standard predefined macros?

655


How to implement a packet in C

2401


What is the use of a static variable in c?

596


Explain the use of keyword 'register' with respect to variables.

593






Array is an lvalue or not?

642


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1677


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1308


explain what are actual arguments?

641


What is a structure member in c?

552


What is the advantage of c?

613


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

650


Is c object oriented?

544


What are pointers? What are different types of pointers?

634


What is multidimensional arrays

637