comp.lang.ada
 help / color / mirror / Atom feed
From: "Theodore E. Dennison" <dennison@escmail.orl.mmc.com>
Subject: Re: C to Ada interfacing
Date: 1996/08/01
Date: 1996-08-01T00:00:00+00:00	[thread overview]
Message-ID: <3200AD3E.41C67EA6@escmail.orl.mmc.com> (raw)
In-Reply-To: 4tm4mg$cjp@optional.cts.com


Lee Slaughter wrote:
> 
> I'm not an Ada programmer but need to interface with Ada
> routines from C (on a VxWorks platform).
> 
> In my probably naive view i'd make a call to someAdaFn( arg )
> and my Ada-programmer peer would define this function in some
> .ada or whatever source file who's
> object file would be linked in with the C .o stuff, and of
> course have to take special care to be sure data types align,
> are in the right order with right number of gaps  and all.
> 
> Is that sort of sketchily it?

It depends on what the someAdaFn does. If it "withs" in other Ada
packages, It probably requires elaboration by the Ada runtime. In this
case, you'll probably have to either - 
   o  write the program's "main" in Ada. It can then call your C code
      which will eventually call someAdaFn. (Ada has better support for
      running C than C does for running Ada).
   o  make a call to the Ada runtime's elaboration routine before you
      call someAdaFn.

Other points:

Since the Ada runtime won't be there (unless you choose the first option
above), someAdaFn can't create or rendezvous with any tasks, and may not
even be able to perform a "delay", or do dynamic allocation. 

You also have to be careful about passing dynamicly-allocated data 
between Ada and C. I have seen situations where this caused problems
that could only be solved by redefining "malloc" to call an Ada routine
to do the dynamic allocation.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




      parent reply	other threads:[~1996-08-01  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-30  0:00 C to Ada interfacing Lee Slaughter
1996-07-31  0:00 ` Paul Hussein
1996-08-01  0:00   ` David Wheeler
1996-07-31  0:00 ` PR MITTON
1996-08-01  0:00 ` Theodore E. Dennison [this message]
replies disabled

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