liveBook · Manning

Internal linkage

As explained in Modern C

Internal linkage is C identifier linkage that restricts an entity's correspondence to a single translation unit.

A private file-level definition

static int cache; static void reset(void) { cache = 0; } The static declarations give cache and reset internal linkage: each identifier corresponds only within this translation unit. An object file elsewhere cannot use these declarations to refer to the same entities. section 13.2

TAKEAWAY: Linkage belongs to identifiers, not the objects they designate. Internal linkage keeps an identifier's correspondence within one translation unit, while external linkage allows declarations in different object files to designate the same entity through the linker. section 13.2

Keep these distinctions separate:

  • static storage duration describes how long an object exists; the storage-class specifier static enforces internal linkage. section 13.2
  • The static specifier can apply to a file-scope or block-scope variable, or to a function. section 13.2
  • extern does not necessarily mean external linkage; it can refer to an identifier with internal linkage. section 13.2

How Modern C covers it

How deep it goes
Explains identifier linkage, linker correspondence, scope, and storage-duration distinctions, while deferring fuller declaration combinations to a reference table.
Examples
Illustrates internal linkage through static variable and function declarations, alongside shadowing examples and a declaration table.
What it assumes
Assumes basic declarations and object files while distinguishing storage duration, lifetime, visibility, and linkage.
What you can do after
Evaluate whether declarations can correspond across object files and distinguish linkage from storage duration.
How it connects
Connects internal linkage with external linkage, storage duration, scope, storage classes, translation units, object files, and the linker.

Also explained in

Compare how 2 books explain internal linkage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.