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

How do you sort filenames in a directory?

957


How can I get random integers in a certain range?

801


What is array of structure in c?

809


What is an operator?

855


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1941


Write a program to print factorial of given number without using recursion?

783


What is the use of define in c?

805


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

891


What are formal parameters?

860


What does the function toupper() do?

884


What is the use of ?: Operator?

898


Describe the order of precedence with regards to operators in C.

845


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

832


Explain goto?

924


Can you tell me how to check whether a linked list is circular?

1079