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;
}
Содержание 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: ......