In C programming, the keyword that restricts a variable or function to the file in which it is declared is static.
At file scope, declaring an object or function with static gives it internal linkage. That means code in other translation units cannot refer to that identifier by name, helping a source file keep implementation details private. The more precise C term is “translation unit,” because preprocessing expands a source file and its included headers into the unit compiled by the compiler.
The keyword has another important meaning inside a function. A block-scope static variable has static storage duration: it is initialized once and retains its value between function calls. Thus, static can describe either file-limited linkage at the top level or persistent storage duration for a local variable.
This is commonly confused with extern. An extern declaration generally refers to an object or function with external linkage, allowing it to be defined in one translation unit and used in another. The auto and register keywords instead concern automatic storage, with register historically suggesting that a local variable be kept in a processor register.