GNU Pascal calls GNU C
I have sorted out GNU C calls GNU Pascal which is in another thread. I have almost got Pascal to call C, but I can't get the variables to transfer properly. I would be grateful for any ideas. Files attached ccall.c, pcallc.p ccall.h and Makefile.
ccall.c
[
#include <stdio.h>
#include "ccall.h"
void world (void)
{
printf("\nHello World\n");
}
void world1 (int *i)
{
printf("In C, I = %i\n",i);
i = 99;
printf("In C, i = %i\n",i);
}
]
ccall.h
[
extern void world(void);
extern void world1(int *i);
]
pcallc.p
[
program pascalcallsC(input,output);
procedure world; external name 'world';
procedure world1(var p : pointer); external name 'world1';
var
i : integer;
p : pointer; {pointer is a Borland extension}
begin
writeln("Hello world from Pascal");
world;
i := 2;
p := @i;
world1(p);
writeln("I = ",i);
end.
]
Makefile:
[
pcallc : pcallc.p ccall.o
gpc -o pcallc pcallc.p ccall.o
ccall.o : ccall.c
gcc -c ccall.c
clean:
rm *.o pcallc
]
|