
70 Pascal 4.0 User’s Guide
4
You can also separate the compilation and linking or loading steps, as follows:
hostname% pc program_unit.p -c
hostname% pc module_unit.p -c
hostname% pc program_unit.o module_unit.o
In this case, you call pc on each unit with the “compile only” option (-c),
which produces an object file with the extension .o. When you use this
option, the compiler driver does not call the linker, ld. You then call pc a
second time, giving the names of the object files, and pc calls pc3 to check for
name and type conflicts before calling the linker.
Calling the linker or loader ld(1) directly does not have the same effect as
calling pc; when you call ld(1) directly, the files are linked and loaded, but
they are not checked for conflicts.
Using Units and Header Files
A complex program may have many routines defined in modules. Each
routine must have a declaration (for example, procedure proc; extern;) in
each file that calls the routine. The easiest way to be sure that you have a
correct and consistent set of declarations is to create a header file.
A header file is a file that contains a set of declarations, nothing else. You use
a header file by using an include directive to include the header file in the
compilation.
For example, here is a modified version of the program, program_unit, that
uses a header file:
In this case, the content of header.h is very simple:
program program_unit2 (output);
include "header.h"
begin
say_hello
end.
procedure say_hello; extern;
Comentarios a estos manuales