Wednesday, March 31, 2010

static keyword

C and related languages

In the C programming language and its descendants, the term static variable has at least three separate meanings, each related to the semantics of C's static keyword:
Static global variables are declared as "static" at the top level of a source file. Such variables are not visible outside the source file ("file scope"), unlike variables declared as "extern".
Static local variables are declared inside a function, just like automatic local variables. They have the same scope as normal local variables, differing only in "storage duration": whatever values the function puts into static local variables during one call will still be present when the function is called again.

No comments:

Post a Comment