static (keyword)

The effect of the keyword varies depending on the details of the specific programming language, most commonly used to modify the lifetime (as a static variable) and visibility (depending on linkage), or to specify a class member instead of an instance member in classes.

C was developed as a successor of B, and the static and register keyword were added as storage class specifiers, along with auto and extern, which kept their meaning from B.

The static keyword is used in many programming languages to specify a local variable to have a lifetime of the whole program, preserved between function invocations, instead of having its own copy for each function invocation as in automatic storage duration, inherited from the usage in C. Examples of programming languages which support the usage of static keyword for local variables to be kept across invocation include such as C, C++, Objective-C, C#, PHP.

The following programming languages with C-like syntax do not support static local variables as in C: Java, JavaScript, Dart.

The static keyword in C, when used as a top-level declaration, makes the variable or function visible to its own compilation unit only.