comp.lang.ada
 help / color / mirror / Atom feed
From: kilgallen@eisner.decus.org (Larry Kilgallen)
Subject: Re: Linking an ADA routine to a program written in C
Date: 1996/09/19
Date: 1996-09-19T00:00:00+00:00	[thread overview]
Message-ID: <1996Sep19.075836.1@eisner> (raw)
In-Reply-To: 01bba5e0$cf06b040$328371a5@dhoossr.iquest.com


In article <01bba5e0$cf06b040$328371a5@dhoossr.iquest.com>, "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:

> This is an implementation-dependent thing.  Generally what has to be done
> is to tell the Ada compiler that the routine is to be called by a C
> compilation unit.  This is done with a pragma such a EXPORT or EXTERNAL,
> depending on the implementation.  Consult your compiler documentation,
> looking especially for discussions of Interface Programming.
> 
> Further, the issue of "withed" packages pretty much requires that your main
> program be an Ada program.  If you already have a suitable "main" program
> written in C, you would need to put an Ada "wrapper" around the C main. 
> The C main might have to be renamed, depending on the Ada implementation,
> because some Ada systems use a routine called "main", which would confuse
> the linker of there were two "main" symbols declared.
> 
> The Ada main program also allows the elaboration code for each compilation
> unit to be called before the main program begins execution.
> 
> The only kind of Ada unit which can be called from C is one in which there
> is NO elaboration code in the unit, or in any of the other Ada units it
> "withs".

Although the restrictions listed may be overly broad.  Although I
don't really use C, I do use shareable libraries with DEC Ada on
VMS (both platforms), and from what I understand of the mechanism
using C, even as the main program, should not be a barrier to
elaboration.  Perhaps I have just been lucky, but with 160,000 lines
of code, I have never had to worry about "elaboration", it "just
happens".  It uses the LIB$INITIALIZE mechanism, which would surely
not be inhibited by intermixing C.

Larry Kilgallen




  reply	other threads:[~1996-09-19  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-18  0:00 Linking an ADA routine to a program written in C newmans
1996-09-18  0:00 ` Larry Kilgallen
1996-09-19  0:00 ` David C. Hoos, Sr.
1996-09-19  0:00   ` Larry Kilgallen [this message]
1996-09-20  0:00     ` Calius
1996-09-20  0:00       ` Chris Brand
1996-09-24  0:00   ` Cyrille Comar
1996-09-25  0:00     ` Larry Kilgallen
1996-09-26  0:00 ` Jens Jakob Jensen
  -- strict thread matches above, loose matches on Subject: below --
1996-09-28  0:00 Robert Dewar
1996-09-28  0:00 ` Larry Kilgallen
1996-10-03  0:00   ` Robert Dewar
1996-10-04  0:00 Larry Kilgallen
1996-10-08  0:00 ` Robert Dewar
replies disabled

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