Inlining replaces a function call with the called function’s implementation. Removing the call can avoid stack setup, control-flow transfer, cache disruption, and copying of struct return values. section 16.1
A definition visible to the compiler
When caller and callee occur in the same translation unit, a compiler may inline the callee. Seeing its instructions in the caller’s context can expose dead branches, already-known computations, and restricted return values for further optimization. section 16.1
Inlining depends on more than declaring a function:
- A traditional C compiler needs the function definition, not merely its declaration. section 16.1
- Definitions placed in headers can make them visible to multiple translation units. section 16.1
- Inline definitions require care because preprocessing can replace function argument names and local variables. section 16.1
// Inline definition in a header file.
// Function argument names and local variables are visible
// to the preprocessor and must be handled with care.
inline
toto* toto_init(toto* toto_x){
if (toto_x) {
*toto_x = (toto){ };
}
return toto_x;
}
Inspect a header-style inline definition and its interaction with preprocessing. section 16.1



