Markus Gerwinski wrote:
I'm currently trying to call a Pascal routine from within a C program. To this mail I attached a few sources demonstrating the way I'm trying to do so. Compiling them with
gpc -c foo.pas gcc footest.c -o footest
leads to an error message "undefined reference to `Bar'".
What am I doing wrong?
a) You must link the Pascal object file:
gcc footest.c foo.o -o footest
b) You must init the RTS etc. (if the Pascal code uses any of it which most Pascal code does), see the demo programs gpc_c_pas.pas and gpc_c_unit.pas.
c) You should specify the asmname of the Pascal routine:
procedure bar; asmname 'Bar';
(Currently, this is the default used by GPC, but this will change soon as a preparationn for qualified identifiers, and you probably don't want your code to break then.)
Frank