comp.lang.ada
 help / color / mirror / Atom feed
From: "Bernard Azria" <azria@cae.ca>
Subject: Re: "extern" procedure in ada
Date: Mon, 30 Sep 2002 18:39:12 -0400
Date: 2002-09-30T22:39:18+00:00	[thread overview]
Message-ID: <anajqm$jbn$1@dns3.cae.ca> (raw)
In-Reply-To: u7kh3o86d.fsf@gsfc.nasa.gov

Thanks to all for your quick responses, It helped me a lot.

I decided to use a pragma import (ada, ..) and to ask people building
the library to define in it, the coreponsding pragma export ( ada,  .. ).
In this way, I shouldn't have to "with " any file from the library.

Thanks again, B.A.

"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:u7kh3o86d.fsf@gsfc.nasa.gov...
> "Bernard Azria" <azria@cae.ca> writes:
>
> > I am looking for the equivallent of an "extern" definition procedure in
> > C for ADA.
> >
> > In other words, how could I define an external procedure to my program
> > without "withing" the package where it is defined ( I have only the
"obj'
> > and the "ali" file of this procedure in a library)
>
> I gather you are trying to use a library that you don't have source
> for? Be careful not to violate your license to use the library.
>
> In order to call any subprogram from Ada, you need the specification of
> the subprogram; the parameter types and return type.
>
> If you have the source code of the subprograms in Ada, you have the
> subprogram specifications.
>
> If you don't have the source code (your case), you need to write the
> specifications yourself, and tell the compiler to get the bodies of
> the subprogram from the library. pragma Import is precisely what you
> need to use for this task.
>
> For a library package, it is usually convenient to group the
> specifications in an Ada package. The package spec contains all the
> subprogram specs, and all the 'pragma Import' statements.
>
> If you are only calling a few subprograms from one place, putting the
> subprogram specifications in the same package where you are calling
> them makes sense.
>
> > Would it be an kind of : pragma import ( ADA, procedure_name )
>
> Yes, exactly. Although, if the library .o is compiled by a different
> compiler than your code, this is not guarranteed to work. You might
> need your vendor to provide an "Ada_GNAT" convention.
>
> --
> -- Stephe





  reply	other threads:[~2002-09-30 22:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-27 19:40 "extern" procedure in ada Bernard Azria
2002-09-28  2:28 ` Jim Rogers
2002-09-28  3:13 ` SteveD
2002-09-28  3:47 ` sk
2002-09-30 14:37 ` Stephen Leake
2002-09-30 22:39   ` Bernard Azria [this message]
2002-10-01 19:57     ` Simon Wright
2002-10-02  1:49       ` Jeffrey Carter
2002-10-02 15:13         ` Bernard Azria
2002-10-02 18:56           ` Jeffrey Carter
replies disabled

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