Returning multiple variables to Pascal
I seem to be making some sort of basic mistake. I can't get the variables to come back again. I attach the files pcallc.p, ccall.c, ccall.h and Makefile. The Pascal program does not get the value 56 back (nor would I expect it to, because it has been passed by value). I have tried various permutations of the use of pointers, but none of them seem to work. How can I change my simple program to get the value 56 back from the C function? I'll again be grateful for your advice. Thanks, Chris pcallc.p [ program pascalcallsC(input,output); procedure world; external name 'world'; procedure w1(i : integer); external name 'w1'; var i : integer; begin writeln("Hello world from Pascal"); world; writeln("Returned from C to Pascal\n"); i := 96; w1(i); writeln("Returned from C again I = ",i); end. ] ccall.c: [ #include <stdio.h> #include "ccall.h" void world (void) { printf("\nHello World from C\n"); } void w1 (int i) { printf("Hello again from C i = %i\n",i); i = 56; } ] ccall.h: [ extern void world(void); extern void w1(int i); ] 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 ccall.o ] Dr Christian Hicks Senior Lecturer, School of Mechanical & Systems Engineering, Stephenson Building, University of Newcastle upon Tyne, NE1 7RU. Phone: +44 191 222 6238 Mobile 0795 8317804 Fax: + 44 191 222 8600 Homepage: http://www.staff.ncl.ac.uk/chris.hicks
participants (2)
-
Dr Christian Hicks -
Eike Lange