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:55:44 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uunet!sea.uu.net!sac.uu.net!dfw.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Interfacing to C library... User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sat, 2 Nov 2002 18:55:18 GMT Content-Type: text/plain; charset=us-ascii References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30311 Date: 2002-11-02T18:55:18+00:00 List-Id: "Eric G. Miller" writes: > Missed that addition since I was looking at a copy of original RM... The version with all the Corrigendum AI's included is available on the net somewhere. Maybe somebody can post the URL? > 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. Don't you mean the other way around? I mean if you're Set-ing a field, you would need a pointer in C. >... 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". You can use access parameters instead of named access types, and then you can say 'Access. Either way, you better make sure the C code doesn't squirrel away a copy of the pointer. You can also pass a System.Address to the C routine, and use 'Address. That's not *so* bad, if you encapsulate it inside a higher-level layer that simply takes an 'in out' parameter, and uses exceptions to indicate errors. >...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... Good idea. (At least *I* think portability to non-GNAT compilers is good, in part because I work for SofCheck, which sells non-GNAT Ada compilers. ;-)) - Bob