Learn C
#include "functions/inline_static.h"

inline & static Functions in C

#concept

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.

#how it works
1

inline hints, rarely commands

Compilers inline by cost model regardless — write inline for tiny hot helpers, measure rather than insist.

2

static inline for headers

Header helpers as static inline dodge C99 inline linkage quirks entirely — one safe pattern to remember.

3

static hides file-privates

static void helper(void) is callable only in its file — same names can coexist in other files collision-free.

4

Internal linkage optimizes

With all callers visible in one file, the compiler inlines, specializes, or eliminates with full knowledge.

#example
#include <stdio.h>
 
static int square(int x) { return x * x; }
 
int main(void) {
printf("%d\n", square(6));
return 0;
}
Output
36
1square is file-private — no other translation unit can see or collide with the name.
2The call likely inlines to 6 * 6 at -O2; either way 36 prints identically.
3Static linkage changed visibility and optimizability, never observable behavior.
#use cases
File-private helpers that must never leak across translation units
Tiny hot-path functions where inlining actually matters (measured)
static inline header utilities without linkage headaches
Catching dead helpers via unused-static-function warnings

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in C yourself — building beats watching.