Use this tag for questions specifically about the effects of the inline keyword, together with the appropriate language tag.


Inlining is a compiler optimization which eliminates function calls by replacing them with the function's code, thus executing it inline

Symbol rule actual

Quality Example

"The keyword inline is more about telling the compiler that the symbol will be present in more than one object file without violating the one definition rule than about actual inlining which the compiler can decide to do or not to do"

from question "Multiple definition of template specialization when using different objects"

Keyword more

"Generally speaking the inline keyword is used more now to allow you to violate the one definition rule when you define a function in a header than to give the compiler a hint about inlining"

from question "C++ Inline methods for performance"


Quality Example

"If a function is static thus not exported anyway and only called once within your code and you never use a pointer to the function chances are good that gcc will decide to inline it automatically as it will have no negative impact the binary won t get bigger by inlining it only once"

from question "Why should I ever use inline code?"

Code longer

"But as the inline code gets longer the savings for inlining become smaller so maybe you could just have a hard limit on the size of the code - any code to be inline must be smaller than the limit"

from question "Extract code from method body and execute it inline using expressions?"

Keyword less

"In reality the inline keyword has less to do with inlining code and more to do with allowing legal violation of the one definition rule"

from question "Is the order of function definitions important for inlining in C++"


"Callee is too large message is printed by c1 when the size in bytecodes of the method being inline is larger than maxinlinesize 35 multiplied by nestedinliningsizeratio 90 on each next level of inlining"

from question "Meaning of "callee is too large" in jvm +LogCompilation output"

Better manually

"If your compiler can do this then writing functions in a way that the compiler is able to inline is better than manually inlining the calls yourself"

from question "Should I consider resource expense of stack frame creation/ movement in method calls - are they significant?"

Generally faster

"A similar argument can be made for inlining functions inline is generally faster but will remain in the same big-o complexity class although there is an additional size tradeoff inlining makes your compiled program larger if the code was being used in many places"

from question "Performance, big O notation, of a recursive an a non-recursive algorithm"


"Templates will be inline in the standard meaning of inline which is more related to the one definition rule than to actual code inlining"

from question "How does templates work, are they always inlined?"

"I m well aware that inline is more of compiler decision than of user going so far as even to inlining non-specified inline-functions so the user control is almost negligible"

from question "Are <function number of lines> and <times function called> considered inverse proportional for inline?"

Fatter code

"Inlining inlining produces fatter code which is faster the inline functions will not appear in the call stack"

from question "Which optimization compiler switches make debugging very hard?"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0