The C–Pascal Interface
115
6
Function Return Values
Function return values match types the same as with parameters, and they
pass in much the same way.
Simple Types
The simple types pass in a straightforward way, as follows:
The commands to compile and
execute
ChrCAVal.p
and
ChrCAValMain.c
with
-calign
hostname% pc -c -calign ChrCAVal.p
hostname% cc ChrCAVal.o ChrCAValMain.c -lpc
hostname% a.out
This is a string
The Pascal function,
RetReal.p
function RetReal(x: real): real;
begin
RetReal := x + 1.0
end; { RetReal }
The C main program,
RetRealMain.c
#include <stdio.h>
extern double RetReal(double);
int main(void)
{
double r, s;
r = 2.0;
s = RetReal(r);
printf(" %f \n", s);
}
Содержание 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: ......