answersLogoWhite

0


Best Answer

Outline functions are primarily advantageous in debug code. By default, functions are never inline expanded in debug code (where NDEBUG is not defined) because debug code should never be optimised. This is simply because it much easier to map the assembly to the source code using outline functions.

In release builds (where NDEBUG is defined), functions are only inline expanded when there is an advantage in doing so. Trivial one-line functions are good candidates, as are complex functions that are only invoked in one place. Functions that increase code size are rarely good candidates so these will remain outline functions. Note that the programmer has no real control over which functions will be inline expanded. In particular, the inlinekeyword has had no bearing on inline expansion since 1998; it is used solely as a linkage directive when defining a non-member function in a header.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the advantage of an outline function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is outline function in c plus plus language?

Outline is the opposite of inline. An inline expanded function is any function or class method where the declaration also provides the definition (the implementation). This is known as implicit inline expansion. Where the definition is kept separate from the declaration, you may use the inline keyword to specifiy that the function should be inline. This is known as explicit inline expansion. Inline expanded functions (whether implied or explicit) does NOT mean the function will in fact be inline expanded. It is merely a suggestion to the compiler. If the compiler's optimisers determine that there is no advantage to be gained by inline expanding a particular function, then that function becomes an outline function. Inline expansion simply means that the body of the function is inserted in place of the function call. Function calls are expensive in terms of memory and performance, so by eliminating the function call completely, your code performs faster and uses less memory. However, functions that are called many times throughout your code will result in a much larger code size, and large code runs slower than small code. Thus the benefit of eliminating a function call has to be weighed against the increased code size. Although some compilers do allow you to override the compiler's inline expansion optimisers, this is strictly non-standard. The best judge of what to expand and what not to expand is best left in the hands of the compiler, and indiscriminate use of the inline keyword should generally be avoided.


Advantage and disadvantage of inline function in c plus plus?

The advantage of an inline function is that it eliminates the function calls completely, thus improving the performance wherever those calls appear. The disadvantage is that it increases code size, which can be detrimental to performance. For this reason, declaring a function for inline expansion is merely a hint to the compiler. If the increased code size would be detrimental, the compiler is free to ignore the inline declaration and retain the function call instead. While the programmer is free to manually expand their own functions, this only serves to increase maintenance should the function ever need to be changed, and could lead to errors should those changes not be propagated correctly. The advantage of having a function, even if it is only ever called once (or from within a loop), is to simplify your code and make it easier to read and maintain. If the function is simple, or is called seldom, then it is a good candidate for expansion, but its almost always better to let the compiler decide which functions should be inline expanded.


What is transistor outline?

its a power distrubut to consumer


What is the principle of tacheometry?

Define tacheometry and outline its principle


What is advantage of software reusability?

What is advantage of software reusability?

Related questions

What is an advantage of using the outline view?

ion know


What is funci n for outline in ppt?

The function for outline in PPT is for intuition help. This can be used on Microsoft Power Point.


What is the advantage of using a sentence outline instead of a topic outline sentence?

well all bass guitars are all them same and you would have to buy the amp with the guitars .


What is the primary advantage of the outline view?

The primary advantage of the outline view is that it allows users to easily organize and structure their content hierarchically. This makes it simpler to see the overall flow of information and make changes to the structure of a document quickly.


What is the function of the worm?

function , purpose , advantage and disadvantage of worm gear


Who developed the consumption function?

The consumption function was developed by John Maynard Keynes. The function was outline in his book titled 'The General Theory of Employment, Interest and Money'.


What is the difference between an outline and inline?

For the inline functions compiler just copies the function code in that place and when the size is too big it treats that function as ordinary function.


What part of speech is the word outlining?

The word "outlining" can function as a verb or a noun, depending on its usage in a sentence. As a verb, it indicates the action of creating an outline. As a noun, it refers to the outline itself.


What is the job of prosecution?

The role of the prosecutor - is to outline the charges and present the evidence against the defendant.


What part of speech is outline?

The word "outline" can function as a noun or a verb. As a noun, it refers to a summary or a plan. As a verb, it means to create a summary or a plan.


What is the outline of exodus?

what is the outline of exodus what is the outline of exodus what is the outline of exodus


What is outline function in c plus plus language?

Outline is the opposite of inline. An inline expanded function is any function or class method where the declaration also provides the definition (the implementation). This is known as implicit inline expansion. Where the definition is kept separate from the declaration, you may use the inline keyword to specifiy that the function should be inline. This is known as explicit inline expansion. Inline expanded functions (whether implied or explicit) does NOT mean the function will in fact be inline expanded. It is merely a suggestion to the compiler. If the compiler's optimisers determine that there is no advantage to be gained by inline expanding a particular function, then that function becomes an outline function. Inline expansion simply means that the body of the function is inserted in place of the function call. Function calls are expensive in terms of memory and performance, so by eliminating the function call completely, your code performs faster and uses less memory. However, functions that are called many times throughout your code will result in a much larger code size, and large code runs slower than small code. Thus the benefit of eliminating a function call has to be weighed against the increased code size. Although some compilers do allow you to override the compiler's inline expansion optimisers, this is strictly non-standard. The best judge of what to expand and what not to expand is best left in the hands of the compiler, and indiscriminate use of the inline keyword should generally be avoided.