Inline function
An inline function is a function defined or designated for incorporation at its use site, either syntactically or through compiler substitution, rather than necessarily invoked through an ordinary call.
Modern C
inline is a C function specifier that permits a function definition to be suitable for direct integration into callers without changing its semantics.
- How it is used
- Uses inline functions to expose optimization opportunities and provide type-safe alternatives to suitable function-like macros.
- How deep it goes
- Explains call replacement, definition visibility, header-based instantiation, and the costs of static header functions.
- Examples
- Uses an unsigned square, a header-defined initializer, and a type-generic floating-point minimum.
- What you can do after
- Apply it by defining header-visible functions, arranging an instantiation, and choosing functions over suitable macros.
Modern C, Third Edition
inline is a C function specifier that permits a definition to suggest inline substitution of a function's body at call sites without requiring the compiler to perform that substitution.
- How it is used
- Uses inline functions to expose small function bodies for optimization and provide type-safe alternatives to function-like macros.
- How deep it goes
- Explains call overhead, optimization opportunities, header definitions, and a single-translation-unit instantiation pattern.
- Examples
- Illustrates a header-defined initializer and contrasts a squaring function with a macro that evaluates count() twice.
- What you can do after
- Evaluate whether inline suits a small function and measure any claimed performance improvement.
Kotlin in Action, 2E
An inline function is a Kotlin function whose body can be substituted at its call sites by the compiler and which can declare reified type parameters.
- How it is used
- Enables efficient higher-order helpers and collection operations while permitting non-local returns from their lambdas.
- How deep it goes
- Explains call-site bytecode substitution, lambda restrictions, performance tradeoffs, and reified runtime type checks.
- Examples
- Uses a locking helper, collection filter/map operations, and filterIsInstance on a mixed String and Int list.
- What you can do after
- Apply it via Kotlin inline and reified declarations to design small lambda-taking helpers and runtime type checks.
Grokking Simplicity
A function defined at the place in a program where it is used rather than assigned to a separate name.
- How it is used
- Uses short anonymous callbacks directly with higher-order functions such as map and withLogging.
- How deep it goes
- Defines inline, anonymous, global, and local functions, then demonstrates callbacks and refactoring limits.
- Examples
- Uses customer emails, greetings, logging, and purchase filtering and mapping to demonstrate inline callbacks.
- What you can do after
- Apply inline functions as map callbacks and recognize when naming a function improves reuse and clarity.
What to know first
- calling conventionA calling convention is a set of binary-interface rules specifying how functions receive arguments, return values, preserve state, and manage calls.
- data conversionData conversion is the transformation of a value or data from one type, format, or representation to another, explicitly or implicitly.
- function typeA function type specifies the types of inputs and result that a callable value accepts and produces.
- header fileA header file is a source file containing declarations, macros, or other shared interface information intended for inclusion in other source files during compilation.
Related concepts
- functionkind of · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- function-like macroalternative to · A function-like macro is a macro invoked with function-like syntax that accepts token input and expands or transforms it into generated source.
- header fileconfigures · A header file is a source file containing declarations, macros, or other shared interface information intended for inclusion in other source files during compilation.
- C99used by · C99 is the ISO standard revision of the C programming language published in 1999.
- filteringincludes · Filtering is the selection or exclusion of data or items according to specified criteria.
- lambdauses · A lambda is an expression that defines an unnamed function, specifying its parameters and body and producing a callable value.
Questions about inline function
What is inline function?
An inline function is a function defined or designated for incorporation at its use site, either syntactically or through compiler substitution, rather than necessarily invoked through an ordinary call.
Which Manning books explain inline function?
Modern C, Modern C, Third Edition, Kotlin in Action, 2E and Grokking Simplicity.
What should I know before learning inline function?
Manning books that teach inline function usually introduce calling convention, data conversion, function type and header file first.
What is the difference between inline function and function-like macro?
An inline function is a function defined or designated for incorporation at its use site, either syntactically or through compiler substitution, rather than necessarily invoked through an ordinary call. A function-like macro is a macro invoked with function-like syntax that accepts token input and expands or transforms it into generated source.
What kinds of inline function are there?
Kinds of inline function include filtering.
What is inline function a kind of?
Inline function is a kind of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



