`inline` — C Keyword

`inline` — C Keyword

The inline keyword in C99: suggests inlining and affects linkage of function definitions in headers.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

inline (C)

A function specifier (C99) that hints to the compiler to inline the function. Combined with static or extern, it controls linkage of inline function definitions across translation units.

Syntax

inline return-type func(params) { body }
static inline return-type func(params) { body }

Example

#include <stdio.h>

static inline int max(int a, int b) {
    return a > b ? a : b;
}

static inline int clamp(int val, int lo, int hi) {
    return max(lo, val) < hi ? max(lo, val) : hi;
}

int main(void) {
    printf("%d\n", max(3, 7));           /* 7 */
    printf("%d\n", clamp(15, 0, 10));    /* 10 */
    return 0;
}

Notes

Example in practice

int main() {
    // Pick one facility from this reference page.
    // Write the smallest program that exercises its main precondition,
    // complexity rule, or lifetime constraint before scaling up.
    return 0;
}