160
Pascal 4.0 User’s Guide
7
The following example shows how to pass simple types:
The C++ function,
RetReal.cc
extern "C"
double RetReal (double &x)
{
return (x + 1.0);
}
The Pascal main program,
RetRealMain.p
program RetRealMain (output);
var
r, s: real;
function RetReal (var x: real): real; external C;
begin
r := 2.0;
s := RetReal (r);
writeln ( r: 4: 1,' Return - ', s: 4: 1);
end.
The commands to compile and
execute
RetReal.cc
and
RetRealMain.p
hostname% CC -c RetReal.cc
hostname% pc RetReal.o RetRealMain.p
hostname% a.out
2.0 Return - 3.0
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......