Calling Ada routines from C programs.

Mark Culp mark at array.UUCP
Sat Feb 16 05:14:48 AEST 1991


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 at 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



More information about the Comp.lang.c mailing list