Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

inline — function specifier

`inline` suggests fast calls but does not force inline expansion. It also affects function-definition rules.

Version: C23; repository compiler flag, production runtime not attested

Syntax

static inline int square(int x) { return x * x; }

inline is a function specifier, not a macro. It suggests call optimization; the compiler need not expand calls inline.

static inline gives the function internal linkage: each translation unit has its own function. This is useful for definitions in headers.

With external linkage, if every file-scope declaration contains inline without extern, the definition supplies no external definition. A used function still requires one. An extern inline definition supplies an external definition; do not duplicate it across translation units.

Examples

#include <stdio.h>

static inline int square(int x)
{
    return x * x;
}

int main(void)
{
    printf("%d\n", square(7));
    return 0;
}

Result

49

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources