Global variables in c and pascal – HP SunSoft Pascal 4.0 User Manual

Page 157

Advertising
background image

The C–Pascal Interface

133

6

functions can be passed to other languages as arguments, the static links for all
procedure or function arguments are placed after the end of the conformant
array bounds pairs, if any.

Routines in other languages can be passed to Pascal; a dummy argument must
be passed in the position normally occupied by the passed routine’s static link.
If the passed routine is not a Pascal routine, the argument is used only as a
placeholder.

Global Variables in C and Pascal

If the types are compatible, a global variable can be shared between C and
Pascal.

An example:

The Pascal procedure,

GloVar.p

var

Year: integer;

procedure GloVar;

begin

Year := 2001

end; { GloVar }

The C main program,

GloVarMain.c

#include <stdio.h>

extern void GloVar();

int Year;

int main(void)

{

Year = 2042;

GloVar();

printf( " %d \n", Year ) ;

}

Advertising