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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e82cb45ab839370 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Interfaces.C and void * Date: 1999/09/22 Message-ID: <7sbc65$pms$1@nnrp1.deja.com>#1/1 X-Deja-AN: 528145703 References: <87btavxw93.fsf@deneb.cygnus.argh.org> X-Http-Proxy: 1.0 x35.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Wed Sep 22 19:54:52 1999 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I) Date: 1999-09-22T00:00:00+00:00 List-Id: In article <87btavxw93.fsf@deneb.cygnus.argh.org>, Florian Weimer wrote: > Recently, I wrote a binding for a C library which provides an abstract > data type and completely hides the underlying representation of the type > (i.e., all the public routines work on pointers to void). > > Is there really no portable equivalent of a C void * in Interfaces.C? > I used Interfaces.C.Strings.chars_ptr, which should be quite portable in > practice, but AFAIK, ISO C doesn't require the representation of void * > and char * to be identical. I generally see "void *" used in two cases: o A routine returns a pointer to an object whose type is determined at runtime. o The object that a routine returns is meant to be an opaque type. In the first case it doesn't matter much what you declare as the parameter type, as long as you use a properly mapped type when you actually try to read the data out of the object. If clients can know prior to the call which type it should be returning, you can even make several bindings (one for each type). In the second case I suspect the closest conceptual equivalent in Ada would be System.Address. But since the C routines must typically be used to create and delete such objects, it really doesn't matter too much what type you choose to represent it as in Ada, as long as its the same size. -- T.E.D. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.