comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: including C routines in Ada (newbie ask for assistance)
Date: Mon, 7 May 2001 10:00:19 -0400
Date: 2001-05-07T14:00:20+00:00	[thread overview]
Message-ID: <9d69pk$sh$1@nh.pace.co.uk> (raw)
In-Reply-To: 3AF68F86.7DA2B0C9@earthlink.net

Good advice. Its also important to observe that whatever functions are
written in C are outside the scope of Ada, and that one needs to figure out
the compilation/linking of C code into a callable library strictly from the
C perspective. Once you have a callable/linkable file Ada can take over &
specify how the Ada program can reach the function. The specifics, of
course, are going to be very dependent on the implementations of the two
languages.

That is to say that two mismatched compilers might never be able to hook
code together since there is nothing mandatory about how a C compiler must
present its interface {calling sequence & parameter passing} and the Ada
compiler attempting to connect to it via pragmas is only going to do so via
some specific conventions that it knows about. Gnat will know about the gcc
method of interfacing, which is probably the same as what the underlying OS
uses for its C-written calls, but with some other compiler at the other end,
you get no guarantees. So its important to state what the environment is
when trying to figure this stuff out.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Marc A. Criley" <mcqada@earthlink.net> wrote in message
news:3AF68F86.7DA2B0C9@earthlink.net...
> Noam Kloos wrote:
> >
> > Hi Once I had someone show me how to write routines in C and import
> > them into Ada source with pragma Import(....);
> > I know how to do a system call pragma import(C,C_System,"system"); but
> > how do I access a c source file I have written myself?
>
> If you're using GNAT, look in the GNAT User Guide in the section on
> "Mixed Language Programming/Interfacing to C", and look at the
> "use_of_import.adb" example in the GNAT examples directory.
>






  reply	other threads:[~2001-05-07 14:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-07 10:57 including C routines in Ada (newbie ask for assistance) Noam Kloos
2001-05-07 13:01 ` Marc A. Criley
2001-05-07 14:00   ` Marin David Condic [this message]
2001-05-07 17:39     ` David Starner
2001-05-07 21:17       ` Marin David Condic
2001-05-09  5:39 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox