5

Using the -xlOption

When you use the xloption, variables and top-level procedures and functions declared in the program unit default to private. Look at the difference when you compile and execute shrvar_prog.p and shrvar_mod.p with xl. See the source code in “Sharing Public Variables” on page 77.

The commands to compile and execute shrvar_prog.p and shrvar_mod.p with the –xloption

hostname% pc -xl shrvar_prog.p shrvar_mod.p shrvar_prog.p:

shrvar_mod.p: Linking: hostname% a.out

From MAIN, before PROC: 1

From PROC : 0

From MAIN, after PROC: 1

Without xl, the variable global in shrvar_mod.p is treated as public; here, global is treated as private. Thus, the assignment:

global := global + 1;

is not reflected in shrvar_prog.p; instead, each file uses its own private copy of global.

The following sections describe five ways of sharing variables and routines across units when you compile your program with xl.

Using public var Declarations

The following examples uses the public attribute in the var declaration to make global public when you compile your program with –xl.

80

Pascal 4.0 User’s Guide