GNU Pascal calls GNU C
Hi, I am trying to write some examples to demonstrate calling C functions from Pascal. I can call void functions with no parameters, but I am wanting to be able to pass variables. My efforts so far include pcallc.p, ccall.c, ccall.h and Makefile. If function w1 and references to it are removed, it works fine. I am just wanting to learn how to pass variables. Any help would be gratefully received. Many thanks, Chris pcallc.p: [ program pascalcallsC(input,output); procedure world; external name 'world'; procedure w1(i : integer); external name 'w1'; var i : integer; external name 'i'; begin writeln("Hello world from Pascal"); world; writeln("Returned from C to Pascal\n"); i := 96; w1(i); writeln("Returned again from C\n"); 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); } ] 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 -
Prof. A Olowofoyeku (The African Chief)