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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b16d5240727960c4 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!fr.ip.ndsoftware.net!proxad.net!newsfeed.stueberl.de!newsrout1.ntli.net!news-in.ntli.net!newspeer1-win.server.ntli.net!newsfe1-win.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: C bindings, Interfaces.C.Pointers etc. User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-ID: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Thu, 13 May 2004 16:26:57 +0100 NNTP-Posting-Host: 81.100.88.147 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe1-win 1084461963 81.100.88.147 (Thu, 13 May 2004 11:26:03 EDT) NNTP-Posting-Date: Thu, 13 May 2004 11:26:03 EDT Organization: ntl Cablemodem News Service Xref: controlnews3.google.com comp.lang.ada:546 Date: 2004-05-13T16:26:57+01:00 List-Id: On Tue, 11 May 2004 18:48:57 +0000, Jeffrey Carter wrote: > -- struct node { int index; double value; }; > type Node_Info is record > Index : Interfaces.C.Int; > Value : Interfaces.C.Double; > end record; > pragma Convention (C, Node_Info); > > -- struct problem { node **x; }; > type Node_Ptr is access all Node_Info; > pragma Convention (C, Node_Ptr); > type Node_Ptr_Ptr is access all Node_Ptr; > pragma Convention (C, Node_Ptr_Ptr); > type Problem_Info is record > X : Node_Ptr_Ptr; > end record; > pragma Convention (C, Problem_Info); > > This compiles fine. This is an exact duplicate of the C declarations. To > deal with this using a higher level Ada abstraction, you'd wrap > something around this to provide that abstraction. I hadn't thought of doing this - it doesn't seem to provide easy answers for allocation and indexing though. In this application, I am building data structures for use by a C/C++ library. The wrapper you're suggesting (I guess) is for accessing elements of the arrays, and allocating/freeing them. I'd have to check that the additional code didn't impose excessive overheads. The solution I have adopted in the end is based on my idea (4), mentioned by tmoran and Martin Chrischik (see other messages). Thanks! -- Adrian