80
Pascal 4.0 User’s Guide
5
Using the
-xl
Option
When you use the –
xl
option, 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.
Without –
xl
, the variable
global
in
shrvar_mod.p
is treated as
public
;
here,
global
is treated as
private
. Thus, the assignment:
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
.
The commands to compile and
execute
shrvar_prog.p
and
shrvar_mod.p
with the
–xl
option
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
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......