answersLogoWhite

0


Best Answer

An inline function is one where the compiler substitutes the body of the function for its invocation. By doing this, the compiler avoids the cost of setting up and tearing down a function call. This is most effective when dealing with small, one or two line, functions.

A preprocessor macro does the same thing, except that the main compiler never "sees" the original invocation. Again, this is most effective when dealing with small functions.

Is there a difference? Yes and no. The two methods can result in the exact same object code, but (with macros) you lose type checking and other checking of various "problems", such as side effects, that can cause your code to work in an unexpected fashion. THese side effects can be difficult to diagnose with macros, because you don't directly see what is actually being compiled. The down side of both methods is that you have duplicate code in each place. The up side is speed.

The inline attribute is a compiler "hint". The compiler can choose to ignore it. By letting the compiler choose, you can gain performance and/or code size benefits, so it is better to go with inlining - that way, the compiler can catch problems before they become difficult to solve.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between In line Function and Preprocessed in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Difference between line and staff function?

The primary difference between line function and staff function is accountability. Line functions are typically used for sales and production, while staff functions are used in production planning and marketing.


What is the difference between a linear and quadratic function?

A linear function is a line where a quadratic function is a curve. In general, y=mx+b is linear and y=ax^2+bx+c is quadratic.


What is the difference between a line and a line segment?

Yes there is a large difference between the two. A line has no end and a line segment ends.


3 What is the difference between a function procedure and a subroutine procedure?

Both a function and a subroutine are examples of out-of-line execution calls to code. The main difference is that a function call can be part of an expression and returns a value, whereas the subroutine can be called standalone and does not return a value.


What is the difference between a trend line and a line of best fit and how are they useful in analyzing data?

What is the difference between a trend line and a line of best fit


The difference between a tanget and a straight line?

its difference


What is the difference between parallel and perpendicular line on rectangle?

The difference between a perpendicular line and a parallel line is that a perpendicular line crosses or joins, while a parallel line doesn't touch at all.


What is the difference between single line diagram and one line diagram?

There is no difference...same thing


What is the difference between a Diagonal line and an oblique line?

none


What is the difference between line function and staff function?

The departments or employees of a firm that perform the core activities and contribute to its business directly are called line function example manufacturing and marketing. on the other hand the departments or employees that perform the support function and contribute indirectly to the business of a firm are termed as staff function example Human Resource Management and Finance. Rajnish


Discuss various forms of get function supported by the Input stream How are they used?

This function is virtually identical to get(buf, num, delim) version of get ( ). The difference between get(buf, num, delim) andgetline ( ) is that getline ( ) reads and removes the delimiter new - line character from the input stream if it is encountered which is not done by the get ( ) function. Following figure explains the difference between get ( ) and getline ( ) functions :


What is the difference between the calling function and called function?

Function calling is when you call a function yourself in a program. While function invoking is when it gets called automatically.For example, consider this programstruct s{int a,b,s;s(){a=2;b=3;}void sum(){s=a+b;}};void main(){struct s obj; //line 1obj.sum(); // line 2}Here, when line 1 is executed, the function(constructor, i.e. s) is invoked.When line 2 is executed, the function sum is called.