Applying the specifier static to a global variable instructs the compiler to create a global variable
known only to the file in which it is declared. Thus, a static global variable has internal linkage (as
described under the extern statement). This means that even though the variable is global, routines
in other files have no knowledge of it and cannot alter its contents directly, keeping it free from side
effects. For the few situations where a local static cannot do the job, you can create a small file that
contains only the functions that need the global static variable, separately compile that file, and use
it without fear of side effects.
Wednesday, July 23, 2008
static Global Variables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment