On this page
  1. inline
  2. Availability
  3. Syntax & Overview
  4. Notes & Pitfalls
  5. Example

inline

Prev: extern | Up: builtins | Next: restrict
Rel: Preprocessor & Macros
Ref: cppreference — inline
Tags: #public #prog #c #builtins #tier/standard


Availability

Built-in (Function Specifier (C99)) — requires no #include header.

Syntax & Overview

static inline T fn(void) { ... }

Hints the compiler to inline a function body; combine with static in headers (static inline) to avoid multiple-definition linker errors.

Notes & Pitfalls

Example

#include <assert.h>

static inline int clamp(int x, int lo, int hi) {
    return x < lo ? lo : (x > hi ? hi : x);
}
int main(void) { assert(clamp(15, 0, 10) == 10); }

Linked from

Related notes