comp.lang.ada
 help / color / mirror / Atom feed
* Pragma Export and initialized variables
@ 2002-01-23 10:15 Sandro Binetti
  2002-01-23 22:04 ` Robert A Duff
  0 siblings, 1 reply; 9+ messages in thread
From: Sandro Binetti @ 2002-01-23 10:15 UTC (permalink / raw)


Hallo, group.

I have to export some complex procedures written in ADA and import
them in a gtk based environment.

What about my ada initialized variables? Suppose that a variable is
initialized by using the value of a function defined in another
package, I'll find it correctly initialized? Do I have to arrange and
export an "init_variables" procedure?

I'm a little confused ... ;-)

Tnx, Sandro.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-23 10:15 Pragma Export and initialized variables Sandro Binetti
@ 2002-01-23 22:04 ` Robert A Duff
  2002-01-24  8:50   ` Sandro Binetti
  0 siblings, 1 reply; 9+ messages in thread
From: Robert A Duff @ 2002-01-23 22:04 UTC (permalink / raw)


sandrobinetti@yahoo.com (Sandro Binetti) writes:

> I have to export some complex procedures written in ADA and import
> them in a gtk based environment.
> 
> What about my ada initialized variables? Suppose that a variable is
> initialized by using the value of a function defined in another
> package, I'll find it correctly initialized? Do I have to arrange and
> export an "init_variables" procedure?

You need to call adainit and adafinal on the C side before calling
anything on the Ada side.

- Bob



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-23 22:04 ` Robert A Duff
@ 2002-01-24  8:50   ` Sandro Binetti
  2002-01-24 18:14     ` Stephen Leake
  0 siblings, 1 reply; 9+ messages in thread
From: Sandro Binetti @ 2002-01-24  8:50 UTC (permalink / raw)


Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message 

> You need to call adainit and adafinal on the C side before calling
> anything on the Ada side.

Hi Bob, tnx for your answer.

I read about "adainit" and "adafinal" inside the L.R.M., but the thing
isn't so clear to me. Where are these procedures defined? Which object
do I have to include into the C project?

Of course, I'm a gnat user ... ;-)

Bye, Sandro.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-24  8:50   ` Sandro Binetti
@ 2002-01-24 18:14     ` Stephen Leake
  2002-01-24 19:29       ` Pascal Obry
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Leake @ 2002-01-24 18:14 UTC (permalink / raw)


sandrobinetti@yahoo.com (Sandro Binetti) writes:

> Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message 
> 
> > You need to call adainit and adafinal on the C side before calling
> > anything on the Ada side.
> 
> Hi Bob, tnx for your answer.
> 
> I read about "adainit" and "adafinal" inside the L.R.M., 

Um, no, these are GNAT terms, not Ada terms. You must have seen them
in the GNAT user guide.

> but the thing isn't so clear to me. Where are these procedures
> defined? Which object do I have to include into the C project?

Read the GNAT user guide again (and again ...), the section titled "A
Simple Example". It talks about C++, but C is similar, only simpler :).

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-24 18:14     ` Stephen Leake
@ 2002-01-24 19:29       ` Pascal Obry
  2002-01-24 22:38         ` Larry Kilgallen
  0 siblings, 1 reply; 9+ messages in thread
From: Pascal Obry @ 2002-01-24 19:29 UTC (permalink / raw)



Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> > I read about "adainit" and "adafinal" inside the L.R.M., 
> 
> Um, no, these are GNAT terms, not Ada terms. You must have seen them
> in the GNAT user guide.

No. This is in Ada RM B.1.39.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-24 19:29       ` Pascal Obry
@ 2002-01-24 22:38         ` Larry Kilgallen
  2002-01-25  3:08           ` Robert Dewar
  0 siblings, 1 reply; 9+ messages in thread
From: Larry Kilgallen @ 2002-01-24 22:38 UTC (permalink / raw)


In article <uvgdrr1j0.fsf@wanadoo.fr>, Pascal Obry <p.obry@wanadoo.fr> writes:
> 
> Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:
> 
>> > I read about "adainit" and "adafinal" inside the L.R.M., 
>> 
>> Um, no, these are GNAT terms, not Ada terms. You must have seen them
>> in the GNAT user guide.
> 
> No. This is in Ada RM B.1.39.

I see them mentioned on http://www.adapower.com/rm95/arm95_265.html
in B.1.6 (with no B.1.39 present).  But their use is just a mechanism
recommended for "typical systems".  Certainly Compaq Ada (83) takes
care of elaboration in this circumstance without any special call,
but that started in 1986 and was originally missing due to a VMS
operating system shortcoming.  Finalization should be possible
with a similar mechanism, although I presume GNAT uses something
that works the same way as on other platforms.  For initialization,
however, I would hope that GNAT on VMS would be arranged to take
existing Compaq Ada code without adding such calls.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-24 22:38         ` Larry Kilgallen
@ 2002-01-25  3:08           ` Robert Dewar
  2002-01-25 12:47             ` Marc A. Criley
  2002-01-25 13:03             ` Larry Kilgallen
  0 siblings, 2 replies; 9+ messages in thread
From: Robert Dewar @ 2002-01-25  3:08 UTC (permalink / raw)


Kilgallen@SpamCop.net (Larry Kilgallen) wrote in message news:<7rHjSipcl0PM@eisner.encompasserve.org>...
>  Certainly Compaq Ada (83) takes
> care of elaboration in this circumstance without any special call,


You miss the point here. The adainit and adafinal
procedures recommended in the RM deal with the situation where you
want specific control over when the Ada initialization and
finalization occur in a mixed language
program. It is absolutely essential to have a specific call for this
level of control, which was not available in any
Ada 83 system.

You may well for example want to finalize an Ada subsystem
long before the final termination of the program.

Actually we find in the GNAT world that having only one
such set of entry points is inadequate, and the latest
version of GNAT has a special switch for gnatbind, -L
that can override the standard adainit/adafinal names. 
This allows different Ada subsystems or libraries to
be separately initialized and finalized as required at
the time required.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-25  3:08           ` Robert Dewar
@ 2002-01-25 12:47             ` Marc A. Criley
  2002-01-25 13:03             ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: Marc A. Criley @ 2002-01-25 12:47 UTC (permalink / raw)


Robert Dewar wrote:
> 
> Actually we find in the GNAT world that having only one
> such set of entry points is inadequate, and the latest
> version of GNAT has a special switch for gnatbind, -L
> that can override the standard adainit/adafinal names.
> This allows different Ada subsystems or libraries to
> be separately initialized and finalized as required at
> the time required.

This is a good thing.  A few years ago I had to compile a bunch of
source code into a shared library, and we were using GNAT to do this. 
So as not to interfere with the calling program's own adainit and
adafinal functions, I had GNAT generate and retain the source code for
those functions, manually renamed them, then compiled them into the
library.  Glad to see that this situation has been recognized, and can
be handled more cleanly.

Marc A. Criley
Consultant
Quadrus Corporation
www.quadruscorp.com



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Pragma Export and initialized variables
  2002-01-25  3:08           ` Robert Dewar
  2002-01-25 12:47             ` Marc A. Criley
@ 2002-01-25 13:03             ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: Larry Kilgallen @ 2002-01-25 13:03 UTC (permalink / raw)


In article <5ee5b646.0201241908.810e556@posting.google.com>, dewar@gnat.com (Robert Dewar) writes:
> Kilgallen@SpamCop.net (Larry Kilgallen) wrote in message news:<7rHjSipcl0PM@eisner.encompasserve.org>...
>>  Certainly Compaq Ada (83) takes
>> care of elaboration in this circumstance without any special call,
> 
> 
> You miss the point here. The adainit and adafinal
> procedures recommended in the RM deal with the situation where you
> want specific control over when the Ada initialization and
> finalization occur in a mixed language
> program. It is absolutely essential to have a specific call for this
> level of control, which was not available in any
> Ada 83 system.

From previous discussion in this newsgroup, I was under the impression
that adainit had to be called by the foreign main program to get the
elaboration code to be executed at all, especially when the Ada code
was in a shareable image (DLL).

Is elaboration handled automatically for the default case in all
environments where Ada is called from a foreign language ?



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-01-25 13:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-23 10:15 Pragma Export and initialized variables Sandro Binetti
2002-01-23 22:04 ` Robert A Duff
2002-01-24  8:50   ` Sandro Binetti
2002-01-24 18:14     ` Stephen Leake
2002-01-24 19:29       ` Pascal Obry
2002-01-24 22:38         ` Larry Kilgallen
2002-01-25  3:08           ` Robert Dewar
2002-01-25 12:47             ` Marc A. Criley
2002-01-25 13:03             ` Larry Kilgallen

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