comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Interfacing to C: big structures
Date: Wed, 27 Feb 2008 09:12:06 -0800 (PST)
Date: 2008-02-27T09:12:06-08:00	[thread overview]
Message-ID: <21af9a6a-d522-4ba5-9d67-68eace9cd1b1@n77g2000hse.googlegroups.com> (raw)
In-Reply-To: m27igr4i0b.fsf@mac.com

On Feb 26, 11:47 am, Simon Wright <simon.j.wri...@mac.com> wrote:
> Adam Beneschan <a...@irvine.com> writes:
> > I thought of something like this, but Maciej said something about
> > wanting to avoid dynamic memory, and it seems that you're defining a
> > type whose size isn't going to be known until runtime, and therefore
> > if you declare an Ada variable of that type, it will have to be
> > allocated dynamically in some way.
>
> That was the cunning trick: the size is known at *elaboration* time!

Isn't that part of "runtime"?  I'm not sure I get your point.  In the
typical compile/link/execute model, as I understand it, the function
that returns the size isn't going to be "called" by the linker, and
probably not by the loader when the program is executed; so the
function will be called when the program starts executing, which means
that any objects of that type can't be allocated until after execution
starts, which means "dynamic allocation" more or less by definition.
However, as others have pointed out, it's not clear exactly what kinds
of dynamic allocation need to be avoided here, and which ones might be
OK.

                             -- Adam

>
> procedure Main_Program is
>   type T is Ada.Streams.Stream_Element_Array (1 .. Size_Returned_From_C);
>   V : aliased T;




  parent reply	other threads:[~2008-02-27 17:12 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 21:17 Interfacing to C: big structures Maciej Sobczak
2008-02-25 23:26 ` Randy Brukardt
2008-02-25 23:26 ` Randy Brukardt
2008-02-27 13:23   ` Maciej Sobczak
2008-02-25 23:26 ` Randy Brukardt
2008-02-25 23:43 ` Robert A Duff
2008-02-26 13:53   ` Stephen Leake
2008-02-26 21:12     ` Randy Brukardt
2008-02-26  2:36 ` Steve
2008-02-26 12:00 ` Alex R. Mosteo
2008-02-26 14:05   ` Robert A Duff
2008-02-26 15:19     ` Alex R. Mosteo
2008-02-26 15:33       ` Robert A Duff
2008-02-26 16:21         ` Alex R. Mosteo
2008-02-27  1:28           ` Robert A Duff
2008-03-10  1:38             ` David Thompson
2008-02-26 17:35   ` Adam Beneschan
2008-02-26 19:47     ` Simon Wright
2008-02-26 21:14       ` Randy Brukardt
2008-02-27  1:40         ` Robert A Duff
2008-02-27 17:12       ` Adam Beneschan [this message]
2008-02-27 20:37         ` Simon Wright
2008-02-28 11:30         ` Alex R. Mosteo
2008-02-28 15:53           ` Robert A Duff
2008-02-29 10:45             ` Alex R. Mosteo
2008-02-27  1:37     ` Robert A Duff
2008-02-27 13:49       ` Maciej Sobczak
replies disabled

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