liveBook · Manning

Inlining

As explained in Modern C

Inlining is a compiler transformation that replaces a function call with the called function's implementation in the caller's context.

Inlining replaces a function call with the called function's implementation in the caller's context. It removes call overhead and lets the compiler optimize the callee alongside surrounding code. section 15.1

Making an inline definition visible

A header can contain an inline definition such as toto_init. Including that definition lets a compiler that knows the callee replace calls and detect dead branches, known results, or restricted return values. section 15.1

Inlining depends on how function definitions are made visible:

  • Compile concatenated project code as one large translation unit, while avoiding definition cycles and naming conflicts. section 15.1
  • Place definitions in headers included by the required translation units, then arrange declarations and instantiation to avoid multiple definitions. section 15.1

How Modern C covers it

How deep it goes
Explains call overhead, definition visibility, and optimization opportunities without detailing compiler heuristics or generated machine code.
Examples
Uses an inline toto_init definition in a header and a separate declaration for one translation unit.
What you can do after
Apply it via visible C function definitions while managing header inclusion and one-translation-unit instantiation.
How it connects
Connects function calls, translation units, header files, declarations, definitions, and compiler optimization.

Also explained in

Compare how 4 books explain inlining →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.