inline & static Functions in C
inline suggests pasting a tiny function's body at call sites instead of calling — a hint modern compilers largely decide themselves, but also (C99 semantics) a linkage tool with fiddly extern rules best sidestepped by defining inline helpers as static inline in headers.
static on a function means internal linkage: visible only in its own file. File-private helpers should all be static — it prevents name collisions across a project, lets the compiler optimize harder (all callers visible), and warns on unused statics (-Wunused-function) to catch dead code.
inline hints, rarely commands
Compilers inline by cost model regardless — write inline for tiny hot helpers, measure rather than insist.
static inline for headers
Header helpers as static inline dodge C99 inline linkage quirks entirely — one safe pattern to remember.
static hides file-privates
static void helper(void) is callable only in its file — same names can coexist in other files collision-free.
Internal linkage optimizes
With all callers visible in one file, the compiler inlines, specializes, or eliminates with full knowledge.
#include <stdio.h> static int square(int x) { return x * x; } int main(void) { printf("%d\n", square(6)); return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C yourself — building beats watching.