Inline Functions
Learn how the inline keyword is used to reduce function call overhead by expanding small and frequently used functions directly at their call sites.
We'll cover the following...
We'll cover the following...
In previous lessons, we defined and called functions in the usual way: the program transfers control to the function, executes its body, and then returns to the caller. For small functions that are called frequently, this process can introduce slight overhead because each function call requires transferring control to another location in the program.
What is an inline function?
C99 introduced the inline keyword, which allows the compiler to expand the function’s code directly at the point where it is called. This can improve efficiency for small helper functions.
An inline function is declared using the inline keyword: