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!news1.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!peer01.cox.net!cox.net!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C bindings, Interfaces.C.Pointers etc. References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 11 May 2004 18:48:57 GMT NNTP-Posting-Host: 63.184.33.169 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1084301337 63.184.33.169 (Tue, 11 May 2004 11:48:57 PDT) NNTP-Posting-Date: Tue, 11 May 2004 11:48:57 PDT Xref: controlnews3.google.com comp.lang.ada:450 Date: 2004-05-11T18:48:57+00:00 List-Id: Dr. Adrian Wrigley wrote: > Hi folks! > > I have a problem creating a binding to a C library. > > The library makes extensive use of arrays of arrays of structs. > Both levels of arrays are of variable length. > > struct node { int index; double value; }; > struct problem { node **x; }; > > When I attempt to define Ada types for this type of thing, > I find I can't use access types to the arrays with the > necessary C convention. > "warning: this access type does not correspond to C pointer" > is the compiler error. -- 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. -- Jeff Carter "Blessed is just about anyone with a vested interest in the status quo." Monty Python's Life of Brian 73