comp.lang.ada
 help / color / mirror / Atom feed
From: Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de>
Subject: Re: Q: memory management
Date: 1996/06/20
Date: 1996-06-20T00:00:00+00:00	[thread overview]
Message-ID: <uvvpw6u79mx.fsf@chaq.informatik.uni-tuebingen.de> (raw)
In-Reply-To: 9606192037.AA13484@most


>>>>> "Wes" == "W Wesley Groleau (Wes)" <wwgrol@PSESERV3.FW.HAC.COM> writes:

    Wes> :>      subtype Alloc_Buffer is String(1..Num_Chars);
    Wes> :>      type Space_Ptr is access all Alloc_Buffer;
    Wes> :>    ...
    Wes> :>
    Wes> :>      X : Space_Ptr := new Alloc_Buffer;
    Wes> :>    ...
    Wes> :>      Pass_To_Assembler(X.all'Address);

    Wes> Please note that whether you have bounds or not, you do not
    Wes> want to pass the actual pointer to assembler or C or ...

    Wes> An Ada access type is a bit pattern that can be used by code
    Wes> from the same compiler to access the item.  It does not have
    Wes> to be an address, though in most implementations it is.  It
    Wes> also does not have to be the address of the actual item, and
    Wes> in most implementations an access to an unconstrained type is
    Wes> NOT the address of the item.  Mr. Taft's example above is the
    Wes> correct way to let code from another compiler or language get
    Wes> the address of your object.  NOT unchecked conversion from
    Wes> the access type to address.  For some reason, I keep seeing
    Wes> even experienced Ada programmers use the latter (incorrect)
    Wes> method.

And if I use unconstrained arrays ? I think I'd have to pass the address
of the first element. Something like this:

  Pass_To_Assembler(X(X.all'First)'Address)


Well, I think it's time to write a Hello World. Thank you all for the help.

 - hannes




  reply	other threads:[~1996-06-20  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-19  0:00 Q: memory management W. Wesley Groleau (Wes)
1996-06-20  0:00 ` Hannes Haug [this message]
1996-06-20  0:00 ` Hannes Haug
1996-06-20  0:00   ` Robert Dewar
1996-06-21  0:00 ` Hannes Haug
1996-06-21  0:00   ` Robert Dewar
1996-06-25  0:00 ` Hannes Haug
     [not found] <JSA.96Jun26142033@organon.com>
1996-06-27  0:00 ` Q: Memory management Hannes Haug
1996-06-27  0:00 ` Hannes Haug
1996-06-27  0:00   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-06-24  0:00 W. Wesley Groleau (Wes)
1996-06-25  0:00 ` Jon S Anthony
1996-06-26  0:00   ` Robert Dewar
1996-06-25  0:00 ` Hannes Haug
1996-06-25  0:00   ` Robert A Duff
1996-06-25  0:00   ` Tucker Taft
     [not found]     ` <Dtzv4J.9FL@thomsoft.com>
1996-07-17  0:00       ` Robert Dewar
1996-06-27  0:00 ` Hannes Haug
1996-06-15  0:00 Q: memory management Hannes Haug
1996-06-15  0:00 ` Jon S Anthony
1996-06-16  0:00   ` Robert Dewar
1996-06-18  0:00   ` Kent Mitchell
1996-06-15  0:00 ` Robert Dewar
1996-06-16  0:00 ` Hannes Haug
1996-06-17  0:00   ` Tucker Taft
1996-06-17  0:00   ` Hannes Haug
1996-06-18  0:00   ` Hannes Haug
1996-06-18  0:00     ` Tucker Taft
1996-06-19  0:00     ` Hannes Haug
1996-06-18  0:00 ` Jon S Anthony
replies disabled

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