comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <martin@krischik.com>
Subject: Re: Libraries written in Ada
Date: Mon, 22 Nov 2004 18:59:16 +0100
Date: 2004-11-22T18:59:16+01:00	[thread overview]
Message-ID: <1464020.dFWPVBaaRG@linux1.krischik.com> (raw)
In-Reply-To: pan.2004.11.22.16.28.48.665871@ID-174572.user.uni-berlin.de

Thomas Lotze wrote:

> On Mon, 22 Nov 2004 16:58:59 +0100, Martin Krischik wrote:
> 
>> No, Ada packages allow for initialization code to included. Ada itself
>> makes shure all initialisation code is executed - even when several
>> libraries are combined. This happens automaticly when the main procedure
>> is written in Ada.
> 
> Does this mean every package contains its own runtime environment, or does
> every package do some initialization on a common runtime?

Actually both. The common runtime consists of packages as well and every
package may or may not have it's own mini runtime environment. There are
pragma instructions to controll that i.E. "pragma Pure" says that a package
has no runtime environment and does not use another package with a runtime
environment.

Please Note: you are asking very low level questions. Normaly you don't need
to worry about it. Ada as a package orientated language has it all build.

That's unlike C where library management is not part of the language and
elaboration (that the Ada term for initialising the runtime environment)
consists of main () only. 

>> When main is written in another language then the standard demands that
>> "some form of initialisation" is provided. In GNAT this is done be:
>> 
>> void adainit (void);
>> 
>> You can request another name if you like or need.
> 
> This would make it possible to initialize several Ada libraries separately
> in a C main program.

Yes. But unless you use DLLs this is not needed. You tell the binder which
top level packages you need and the binder will recusivly elaborate
everthing needed.

With GNAT you can even control if elaboration order should be calculated
staticly at bind time or dynamicly at run time.

>> The GNAT binder will generate this procedure for you and it will init all
>> libraries involved.

> And this seems to make it necessary, at least if I don't want to expose
> the implementation details of the libraries to the extent that all used
> Ada libraries have to be bound together by GNAT before they can be bound
> to a C main as a whole (or do I get something completely wrong here?).

That's the normal way for static linking. It does have the advantage that
the binder will bind and elaborate only the packages which are actually
used.

> That is, if I have libraries libfoo and libbar written in Ada and
> installed in binary form along with appropriate C include files, can I get
> away without using GNAT if I call both adainit_foo() and adainit_bar() in
> the C main? I think it's much better for library users if they don't have
> to do a separate GNAT binding step but can ignore the fact that there's
> Ada behind the scenes except for the initialization calls.

Well, This looks you pretty much plan a DLL approach. And yes: In an DLL
environment that is what you do. Have the binder create one init per DLL
and then main() must call them one after the other.

GNAT provides the basic Ada packages also as DLL. So no duplicate code here.

With Regards

Martin


-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com



  parent reply	other threads:[~2004-11-22 17:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-22 11:32 Libraries written in Ada Thomas Lotze
2004-11-22 15:58 ` Martin Krischik
2004-11-22 16:28   ` Thomas Lotze
2004-11-22 16:46     ` Alex R. Mosteo
2004-11-22 19:09       ` Pascal Obry
2004-11-23 11:12         ` Alex R. Mosteo
2004-11-22 17:59     ` Martin Krischik [this message]
2004-11-22 20:36       ` Thomas Lotze
2004-11-22 21:25         ` Georg Bauhaus
2004-11-22 21:45           ` Thomas Lotze
2004-11-22 22:07             ` Georg Bauhaus
2004-11-22 22:27               ` Thomas Lotze
2004-11-23  9:54                 ` Adrien Plisson
2004-11-23  9:55                 ` Martin Krischik
2004-11-23  9:55               ` Martin Krischik
2004-11-23  9:48         ` Martin Krischik
2004-11-23 11:03           ` Thomas Lotze
2004-11-23 11:38             ` Alex R. Mosteo
2004-11-23 12:22               ` Georg Bauhaus
2004-11-23 13:20                 ` Alex R. Mosteo
2004-11-23 13:40                   ` Alex R. Mosteo
2004-11-23 12:36             ` Martin Krischik
2004-11-23 13:53               ` Thomas Lotze
2004-11-23 18:39                 ` Jeffrey Carter
2004-11-22 20:45       ` Georg Bauhaus
replies disabled

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