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!news2.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!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: Mon, 25 Feb 2008 18:43:56 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1203983036 13398 192.74.137.71 (25 Feb 2008 23:43:56 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 25 Feb 2008 23:43:56 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:m8mzuIoHnfC9kRSGu051fOyBjMM= Xref: g2news1.google.com comp.lang.ada:20069 Date: 2008-02-25T18:43:56-05:00 List-Id: Maciej Sobczak writes: > Consider the C API that contains some structure S and a couple of > functions that operate on the state that is stored in the Struct. A > typical usage in C might be: > > struct S s; > > init(&s); > foo(&s); > bar(&s); > baz(&s); > > Above, s is created with automatic storage duration. > > How to interface to this from Ada? I see two options: Something like: type S is record ... end record; pragma Convention (C, S); X : aliased S; init (X'Access); -- or possibly 'Unchecked_Access foo (X'Access); -- or ... Best to avoid heap management when you can. - Bob