From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Interfacing to C: big structures
Date: Wed, 27 Feb 2008 05:49:43 -0800 (PST)
Date: 2008-02-27T05:49:43-08:00 [thread overview]
Message-ID: <3709c993-cfb6-4752-9d9f-2450512a820c@t66g2000hsf.googlegroups.com> (raw)
In-Reply-To: wccfxvfji2a.fsf@shell01.TheWorld.com
On 27 Lut, 02:37, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
> I think Maciej is trying to avoid heap allocation, because then you have
> to worry about deallocation.
This might not be the only reason. Another one might be to fulfill the
constraints of high-integrity system.
> But dynamic-sized allocation on the stack
> should be OK in that regard. If you don't like the dynamic size (it
> does introduce some inefficiency), then you could do this:
>
> S_Size : constant := 24; -- or whatever you know it is
> pragma Assert (S_Size = Size_Of_S);
> type S is new Ada.Streams.Stream_Element_Array (1 .. S_Size);
> for S'Alignment use ...;
Yes, this is one of the possibilities.
It can be improved with a script that is executed at build time that
gets the sizeof(S) in C and copies it verbatim to the Ada source file
(it can be a separate source file for exactly this purpose). This way
both consistency and compile-time "constness" can be achieved.
Such a script can be actually part of some bigger activity that
gathers system-specific information. See autotools for example.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
prev parent reply other threads:[~2008-02-27 13:49 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
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 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox