mark@array.UUCP (Mark Culp) (02/16/91)
We have a large application program developed in C that we would like to
port to an underlying operating system (CAIS-A) which is written in Ada.
Before we start on this attempt, we realize that our largest problem is
going to be trying to call an Ada routine from our C program.
I have attempted to call an Ada routine from a C sub-routine (of an Ada
main procedure) using the Telesoft Ada compiler, but have had no success
with the linker resolving the Ada's routine name.
Here is my test Ada source program:
with Text_IO;
procedure Ada_Routine is
begin
Text_IO.Put_Line( "Ada Routine" );
end Ada_Routine;
with Text_IO;
with Ada_Routine;
procedure Test_C_Interface is
procedure C_Main_Routine;
pragma Interface( C, C_Main_Routine );
begin
Text_IO.Put_Line( "Begin" );
C_Main_Routine;
Text_IO.Put_Line( "End" );
end Test_C_Interface;
and here is my test C routine:
#include <stdio.h>
void c_main_routine()
{
printf( "c_main_routine begin\n" );
ada_routine();
printf( "c_main_routine end\n" );
}
I have tried variations on the "ada_routine()" call, but with no success.
If you have attempted to do this, or know how to solve this problem,
I would be grateful to here from you. Please email, I will summarize.
Thanks.
Mark.
---------------------------------------------------------------------------
Mark N. Culp UUCP : {mnetor,utzoo}!lsuc!array!mark
Array Systems Computing Inc. Internet: mark@array
401 Magnetic Drive, Unit 24 Phone : +1(416)736-0900 Fax: (416)736-4715
Downsview, Ont CANADA M3J 3H9 Home : +1(416)857-5290
jls@yoda.Rational.COM (Jim Showalter) (02/18/91)
mark@array.UUCP (Mark Culp) writes:
I believe you are trying to do this backwards. Pragma Interface allows
Ada to call other languages. I do not believe the LRM specifies how
OTHER languages are to call Ada--that would seem to be more the job
of the linker for the other language than of Ada.
Thus, in your example you have written the Ada Test_C_Interface to be able to
call a C function called "C_Main_Routine". This should work (presuming
you have tools sufficient to link the two languages). But then you try
to call ada_routine from your C program. Does your C linker know how
to do this? If not, this won't work.
--
***** DISCLAIMER: The opinions expressed herein are my own. Duh. Like you'd
ever be able to find a company (or, for that matter, very many people) with
opinions like mine.
-- "When I want your opinion, I'll beat it out of you."