From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,575dfcf6488662de X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!newsfeed.stueberl.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Libraries written in Ada Date: Mon, 22 Nov 2004 18:59:16 +0100 Organization: None Message-ID: <1464020.dFWPVBaaRG@linux1.krischik.com> References: <18687975.p80OmDsB1I@linux1.krischik.com> Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1101146799 00 21227 f912Xh2LNvt6SkGh 041122 18:06:39 X-Complaints-To: usenet-abuse@t-online.de X-ID: G5djoMZAQeawuzHiD8xbmNYC1wSiFqkZFoCvuPqylzQHyFNQp3UAoQ User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:6334 Date: 2004-11-22T18:59:16+01:00 List-Id: 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