5

The module unit,

defvar_mod2.p, which defines global in a define declaration

module defvar_mod2;

var

global : extern integer;

define global;

procedure proc;

begin

writeln('From PROC: ',global); global := global + 1;

end; { proc }

The commands to compile and execute defvar_prog.p and defvar_mod2.p

hostname% pc -xl defvar_prog.p defvar_mod2.p defvar_prog.p:

defvar_mod2.p: Linking: hostname% a.out

From MAIN, before PROC: 1

From PROC: 1

From MAIN, after PROC : 2

Using include Files

In the following example, the extern declaration for the variable global is in the include file, inc_prog2.p, and is therefore included in both files. The define declaration in file inc_mod2.p cancels the extern definition.

84

Pascal 4.0 User’s Guide