5

The module unit, ext_mod.p

The include file, extern.h

The commands to compile and execute ext_prog.p and ext_mod.p

module ext_mod;

define

global, proc;

%include "extern.h";

procedure proc;

begin

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

end; { proc }

var

global : extern integer;

procedure proc; extern;

hostname% pc -xl ext_prog.p ext_mod.p ext_prog.p:

ext_mod.p: Linking: hostname% a.out

From MAIN, before PROC: 1

From PROC : 1

From MAIN, after PROC: 2

Sharing Declarations in Multiple Units

Using extern and external directives for procedure and function declarations, you can optionally specify the source language of a separately compiled procedure or function. For example, extern fortran directs the compiler to generate calling sequences compatible with the FORTRAN compiler from SunSoft. Then, external c directs the compiler to generate calling sequences compatible with SunSoft C compiler.

Separate Compilation

87