(This post is related to two earlier posts by me, "Linking Ada to Pascal" and 'Where is documentation for "new argument to _p_initialize (@)" PCStrings.')
I've had some success here. The following two files (Pascal main program) and compile commands work.
<file pascalcallsada.pas> program pascalcallsada (input, output);
procedure youradapackagesubroutine; external name 'myadapackagesubroutine'; procedure adainit; external name 'adainit'; procedure adafinal; external name 'adafinal';
begin adainit; writeln('Hello from pascalcallsada.'); youradapackagesubroutine; writeln('Goodbye from Pascal main program.'); adafinal; end.
<file myadapackage.ads> package myadapackage is
procedure myadapackagesubroutine; pragma Export(Convention => C, Entity => myadapackagesubroutine, External_Name => "myadapackagesubroutine");
end myadapackage;
<file myadapackage.adb> with Ada.Text_IO; use Ada.Text_IO;
package body myadapackage is
procedure myadapackagesubroutine is begin Put_Line("Hello from myadapackagesubroutine."); end myadapackagesubroutine;
begin Put_Line("Initializing myadapackage."); end myadapackage;
<Compile commands> gpc -c pascalcallsada.pas gnatmake -c myadapackage.adb gnatmake -c myadaprogram.adb gnatbind -n myadapackage.ali myadaprogram.ali gnatlink myadaprogram.ali pascalcallsada.o `gpc -print-file- name=libgpc.a` \ -o mypascalprogram
<Out from running> Initializing myadapackage. Hello from pascalcallsada. Hello from myadapackagesubroutine. Goodbye from Pascal main program.
Jerry