From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8ecbc35ea893182f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: big structures Date: Tue, 26 Feb 2008 20:40:09 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <62idb0F23ddfnU1@mid.individual.net> <56a177e4-506f-4bc8-a531-7f2dd15d50c8@i7g2000prf.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1204076409 17143 192.74.137.71 (27 Feb 2008 01:40:09 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 27 Feb 2008 01:40:09 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:hMknaLTYfhpFb3P9dTyDlZmUnBM= Xref: g2news1.google.com comp.lang.ada:20118 Date: 2008-02-26T20:40:09-05:00 List-Id: "Randy Brukardt" writes: > "Simon Wright" wrote in message > news:m27igr4i0b.fsf@mac.com... >> Adam Beneschan 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! >> >> procedure Main_Program is >> type T is Ada.Streams.Stream_Element_Array (1 .. Size_Returned_From_C); >> V : aliased T; > > But at least some compilers will allocate V on the heap (under the covers, > of course) because the size of the object is not know at compile-time. I the compiler does that, I presume it would (under the covers) deallocate the heap object on leaving the relevant scope. > Janus/Ada works this way, for instance. For high-integrity applications, > that's still unacceptable. > > But the OP didn't provide enough information to know if this is acceptable > to him or not. Indeed. - Bob