HP Pascal/iX Programmer's Guide (31502-90023)

9- 7
BEGIN
...
END ;
BEGIN { main program }
{ Actual call to C function Signal }
Dummy := Signal(3 , waddress(Signal_Handler) ) ;
END .
7. Declaring a
long pointer
in C is analogous to declaring an
ordinary pointer in Pascal, except that the "*" is replaced by
"^". For example,
int Func (Rec)
struct Stat ^Rec ;
declares Rec to be a VAR $EXTNADDR$ of type Stat.
8. Limited compatibility exists if the callee is written in C to do
raw I/O (using read(2) or write(2)) on a Pascal file. Such
functions can be called from Pascal by passing the result of a
call to
fnum(pascal_file)
to the C function.
9. If you are passing a real parameter to a C routine that expects a
float you must compile the routine in ANSI mode or with the +r
option to the C compiler. This insures that floats are not
promoted to doubles. Otherwise, you should pass a longreal value.
(For more information refer to the
HP C Programmer's Guide
.
Example 1
The Pascal program Pascal_C calls the external C routine add, passing a
VAR parameter.
Pascal program:
PROGRAM Pascal_C (input,output);
VAR
int1,
int2,
int3 : integer;
PROCEDURE add ( parm1 : integer;
parm2 : integer;
VAR parm3 : integer); EXTERNAL C;
BEGIN
int1 := 25000;
int2 := 30000;
add(int1,int2,int3);
writeln(int3);
END.
C routine:
void add (a,b,c)
int a,b;
int *c;
{
*c = a + b;
}
Example 2
The Pascal program Pascal_C2 calls the external C routine cread. The
Pascal program passes a string parameter to the C routine.