Program Construction and Management
73
4
By default, both definitions of variable
x
are
public
. Thus, when you compile
and link the program and module units, references to
x
refer to the same
variable, as follows:
If you compile the program giving the
-xl
option, the variables are
private
by default, as follows:
You can get the same effect by explicitly declaring the variable in a
private
var
section. Similarly, when you use
-xl
, you can create
public
variables by
declaring them in a
public var
section.
As with routine declarations, it is often a good idea to declare
public
variables in an
include
file. Doing so makes it easier to keep your
declarations consistent.
There are other methods for making variables visible to different units. See
Chapter 5, “Separate Compilation,” for more information.
hostname% pc program_unit3.p module_unit3.p
program_unit.p:
module_unit.p:
Linking:
hostname% a.out
Hello, world for the 1 time.
Hello, world for the 2 time.
Hello, world for the 3 time.
Hello, world for the 4 time.
Hello, world for the 5 time.
hostname% pc -xl program_unit.p module_unit.p
program_unit.p:
module_unit.p:
Linking:
hostname% a.out
Hello, world for the 0 time.
Hello, world for the 0 time.
Hello, world for the 0 time.
Hello, world for the 0 time.
Hello, world for the 0 time.
Содержание 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: ......