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!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: big structures Date: Tue, 26 Feb 2008 15:14:36 -0600 Organization: Jacob's private Usenet server Message-ID: References: <62idb0F23ddfnU1@mid.individual.net> <56a177e4-506f-4bc8-a531-7f2dd15d50c8@i7g2000prf.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1204060729 21313 69.95.181.76 (26 Feb 2008 21:18:49 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 26 Feb 2008 21:18:49 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:20111 Date: 2008-02-26T15:14:36-06:00 List-Id: "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. 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. Randy.