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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e55ee29fd922b5bc X-Google-Attributes: gid103376,public From: William Starner Subject: Re: Interfacing to void * Date: 1999/07/19 Message-ID: <379412E4.9B0E98CF@worldnet.att.net>#1/1 X-Deja-AN: 503020522 Content-Transfer-Encoding: 7bit References: <37929901.649C0955@worldnet.att.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc02.worldnet.att.net 932451054 16992 208.252.201.207 (20 Jul 1999 06:10:54 GMT) Organization: AT&T WorldNet Services Mime-Version: 1.0 Reply-To: dstarner98@aasaa.ofe.org NNTP-Posting-Date: 20 Jul 1999 06:10:54 GMT Newsgroups: comp.lang.ada Date: 1999-07-20T06:10:54+00:00 List-Id: jerry@jvdsys.stuyts.nl wrote: > > William Starner wrote: > > : If I'm trying to interface to a C library that uses this struct > > : struct BigNum { > : void *ptr; > : unsigned int size; > : unsigned int allocated; > : }; > > : how should I interface to void*? > > Depends on what you need to do with the result. Absolutely nothing. I just need to be able to declare a pointer to it and allocate memory for it. > In the most basic case > you could do something like: > > type BigNum is > record > ptr : System.Address; > size : Interfaces.C.unsigned; > allocated : Interfaces.C.unsigned; > end record; > pragma Convention (C, BigNum); > > as a void * basically is a memory address and use > System.Address_To_Access_Conversions to get an access type > to whatever ptr is pointing at. Yes, pragma Convention (C, BigNum). That's probably necessary. I fear that many bugs are going to appear the first time this gets compiled on a non-GNAT compiler, with stuff like that (as GNAT uses C convention for almost everything by default.)