A static helper function keeps implementation details private to one source file.

internal linkage At file scope, `static` limits a helper function to the current translation unit.
small boundary The public code calls a named operation while the helper owns one detail.

Static Helper

input
static_helper.c
Replay: real traced execution (multi-file project)
#include <stdio.h>

static int clamp_to_limit(int value) {
    if (value > 10) {
        return 10;
    }
    return value;
}

int main(void) {
    int input = 12;
    int clamped = clamp_to_limit(input);

    printf("clamped=%d\n", clamped);
    return 0;
}
#include <stdio.h>

static int clamp_to_limit(int value) {
    if (value > 10) {
        return 10;
    }
    return value;
}

int main(void) {
    int input = 7;
    int clamped = clamp_to_limit(input);

    printf("clamped=%d\n", clamped);
    return 0;
}
#include <stdio.h>

static int clamp_to_limit(int value) {
    if (value > 10) {
        return 10;
    }
    return value;
}

int main(void) {
    int input = 15;
    int clamped = clamp_to_limit(input);

    printf("clamped=%d\n", clamped);
    return 0;
}
  1. input ← 12

    10int main(void) {11    int input→ 12 = 12; //@input=7, 1512    int clamped = clamp_to_limit(input12);
  2. static int clamp_to_limit(int value)

    3static int clamp_to_limit(int value12) {4    if (value > 10) {
  3. if (value > 10)

    3static int clamp_to_limit(int value) {4    if (value12 > 10) {5        return 10;6    }
  4. clamped ← 10

    11    int input = 12; //@input=7, 1512    int clamped→ 10 = clamp_to_limit(input12);1314    printf("clamped=%d\n", clamped10);15    return 0;16}
    outputclamped=10
  1. input ← 7

    10int main(void) {11    int input→ 7 = 7;12    int clamped = clamp_to_limit(input7);
  2. static int clamp_to_limit(int value)

    3static int clamp_to_limit(int value7) {4    if (value > 10) {5        return 10;6    }7    return value7;8}
  3. clamped ← 7

    11    int input = 7;12    int clamped→ 7 = clamp_to_limit(input7);1314    printf("clamped=%d\n", clamped7);15    return 0;16}
    outputclamped=7
  1. input ← 15

    10int main(void) {11    int input→ 15 = 15;12    int clamped = clamp_to_limit(input15);
  2. static int clamp_to_limit(int value)

    3static int clamp_to_limit(int value15) {4    if (value > 10) {
  3. if (value > 10)

    3static int clamp_to_limit(int value) {4    if (value15 > 10) {5        return 10;6    }
  4. clamped ← 10

    11    int input = 15;12    int clamped→ 10 = clamp_to_limit(input15);1314    printf("clamped=%d\n", clamped10);15    return 0;16}
    outputclamped=10