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,64a6ad02ec510120 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-02 10:35:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail From: "Eric G. Miller" Subject: Re: Interfacing to C library... User-Agent: Pan/0.13.0 (The whole remains beautiful (Debian GNU/Linux)) Message-ID: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: Sat, 02 Nov 2002 18:35:16 GMT NNTP-Posting-Host: 216.119.6.14 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1036262116 216.119.6.14 (Sat, 02 Nov 2002 10:35:16 PST) NNTP-Posting-Date: Sat, 02 Nov 2002 10:35:16 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:30310 Date: 2002-11-02T18:35:16+00:00 List-Id: In , Robert A Duff wrote: > "Eric G. Miller" writes: > >> Seems Ada always passes records via C pointers. So, the above >> doesn't work. Surely, there's a way! Or do I need a C wrapper for >> my Ada wrapper ;-( > > This is a bug in the Ada 95 language, which, I must admit, is partly my > fault. It has since been "fixed" by adding pragma C_Pass_By_Copy. > See AI-131. This AI is approved by WG9, and is part of Corrigendum 1. > > Perhaps "fixed" is an overstatement. The bug has been patched with a > kludgy pragma. Missed that addition since I was looking at a copy of original RM... Anyway, I don't think the C_Pass_By_Copy semantics quite work the way I want them too (or, it's "kludgy"). All the "Set" routines of this C library take C structs by copy while all the "Get" routines take pointers and all routines return (in the function sense) a long integer status code. I've found if I use access types for the "Get" routines, then I have to worry about aliasing and need to use T'Unchecked_Access or I need to dynamically create the objects via "new". I think I like the GNAT Import_Function()/Import_Procedure() pragmas a little better, since they facilitate finer control over the parameter passing method. However, I'd rather not use compiler specific capabilities...