The C–Pascal Interface
113
6
If no function prototype is provided for
SimVal
in
SimValMain.c
, then
sr:shortreal
must be changed to
sr:real
in
SimVal.p
. This change is
necessary because in C, a
float
is promoted to double in the absence of
function prototypes. In
-xl
mode, change
sr:shortreal
to
sr:longreal
.
Simple Types with
–xl
With
-xl
, the Pascal
real
must be paired with a C
float
, and the Pascal
integer
must be paired with a C
short int
.
The C main program,
SimValMain.c
#include <stdio.h>
extern void SimVal(
char, char, char,
short,
int,
float,
double,
int *);
int main(void)
{
char t = 1, f = 0;
char c = 'z';
short si = 9;
int i = 9;
float sr = 9.9;
double r = 9.9;
int args;
SimVal(t, f, c, si, i, sr, r, &args);
printf(" args = %06o \n", args);
The commands to compile and
execute
SimVal.p
and
SimValMain.c
hostname% pc -c SimVal.p
hostname% cc SimVal.o SimValMain.c -lpc
hostname% a.out
args=111111
Содержание 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: ......