9.20 Keyword 'static' and operator '::'

----------------------------------------

Use of the word 'static' when declaring a global variable, structure or

function means that these will be accessible only in the file in which they

were declared, i. e., if this file is included in another 'include'

directive, the variables declared in the included file and preceded by

'static' will not be available in the basic file, and other variables with

the same names can be declared in the basic file.

Use of 'static' when declaring a local variable in a function means

that memory for this variable will be allocated not in the stack but in the

function data area. But this variable will be accessible only within the

function where it was declared. Using 'static' with a local variable lets

us save the value of the variable for subsequent entry into a function.

You can use 'static' for any global object (variable, structure or

function) but it is restricted in local use to variables only.

If a program contains global and local variables of the same name, then

a function in which the local variable is declared cannot access the global

variable of the same name. Placing a '::' before the name of the variable

allows access to the global variable. For example:

int var; //declare global variable

void proc()

int var; // declare local variable with a name already in

// use by a global variable

{

(E)AX=var; //access only local variable

(E)AX=::var; // access global variable as well as local variable

}