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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e016ae58737f34 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: win32ada design question/problem Date: 1998/11/17 Message-ID: <72shhh$8cg$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 412853582 References: <364C5EDE.4F402D13@elca-matrix.ch> <72i3r9$o1r$1@nnrp1.dejanews.com> <72s2as$pbg$1@nnrp1.dejanews.com> <36519A6A.C07508F5@elca-matrix.ch> X-Http-Proxy: 1.0 x10.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Tue Nov 17 19:07:30 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) Date: 1998-11-17T00:00:00+00:00 List-Id: In article <36519A6A.C07508F5@elca-matrix.ch>, Mats.Weber@elca-matrix.ch wrote: > dennison@telepath.com wrote: > > > > In article , > > Stephen Leake wrote: > > > > > > While I agree it wasn't well designed, I don't agree you need to go to > > > a thick binding. The binding should use 'out' parameter modes in the > > > places where C uses pointers to achieve output parameters. Most > > > compilers will map an 'out' parameter to a C pointer, since that's > > > what 'by reference' means. > > > > Actually, according to B.3(68), that is *required* behavour. The problem with > > that technique is that many C routines attach a signifigance to a incomming > > value of null. You won't be able to produce such a value on the Ada side, so > > some of the functionality of the C routine will be lost. > > And there is another, more severe problem. The C function may allocate > some memory that you must free later, e.g. > > procedure P (X : out Some_Record_Type); > pragma Import(C, P); > > now as you have no pointer to the returned data, you cannot free it. > > I think the Ada 83 classic int + System.Address approach is better in > this case. > I'm trying to write some portable bindings to the Zlib compression library right now, and have found myself reverting to just that. But are there portability issues associated with System.Address? My reading of 13.7 is that System.Address does not nessecarily map to a C pointer, and that System.Null_Address does not nessecarily map to a C null pointer. The "portable" alternative we are given is Interfaces.C.Pointers. But its a real pain to use for routines where the input object could be any type. -- T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own