Procedure calls: pascal–c, Variable parameters, Simple types – HP SunSoft Pascal 4.0 User Manual

Page 141

Advertising
background image

The C–Pascal Interface

117

6

Procedure Calls: Pascal–C

This section parallels the section, “Procedure Calls: C–Pascal” on page 93.
Earlier comments and restrictions also apply here.

Variable Parameters

Pascal passes all variable parameters by reference, which C can do, too.

Simple Types

Simple types pass in a straightforward manner, as follows:

The commands to compile and
execute

IO.p

and

IOMain.c

hostname% pc -c IO.p

hostname% cc IO.o IOMain.c -lpc

hostname% a.out

Hello Pascal and St. Petersburg!

Hello C!

The C function,

SimRef.c

void SimRef(

char

*t,

char

*f,

char

*c,

short

*si,

int

*i,

float

*sr,

double

*r)

{

*t = 1;

*f = 0;

*c = 'z';

*si = 9;

*i = 9;

*sr = 9.9;

*r = 9.9;

}

Advertising