Inline function is a function that can be defined in a header, included into multiple source files and not cause a linker error.
function inlining (a type of compile-time optimization) hasn't depended on the keyword inline in ages: even without it the main() function will consist of the two calls to operator<< (or whatever that expands to) on any sensible compiler.
You cannot force the compiler to inline a particular function, even with the __forceinline keyword
why when using recursion some compilers ignores the inline
Compiler never ignores inline in its required meaning (allowing the function to be included in many source files). Optimizer may choose not to inline a recursive function depending on the contents of the function and the quality of the optimizer.
The inline keyword tells the compiler that inline expansion is preferred. However, the compiler can create a separate instance of the function (instantiate) and create standard calling linkages instead of inserting the code inline. Two cases where this can happen are:
* Recursive functions.
* Functions that are referred to through a pointer elsewhere in the translation unit.
Unless a recursive function undergoes tail-call optimization, and is therefore converted to a single function using a loop, the recursive call needs somewhere to go (i.e. an address) so the function cannot be inlined.