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,1726119712bbda0d X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: Interfacing to C non-void procedure with "out" parameters Date: 2000/01/15 Message-ID: <85omo4$u5q$1@nnrp1.deja.com>#1/1 X-Deja-AN: 572814539 References: <387f1c30.12554815@news.rdg.ac.uk> <85ngl3$10s$1@nnrp1.deja.com> <85nqaf$95o$1@nnrp1.deja.com> <85nurq$cr0$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x31.deja.com:80 (Squid/1.1.22) for client 205.188.199.59 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sat Jan 15 02:41:11 2000 GMT X-MyDeja-Info: XMYDJUIDjrcarter001 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; AOL 5.0; Windows 95; DigExt; Freei Client 2.1) Date: 2000-01-15T00:00:00+00:00 List-Id: In article <85nurq$cr0$1@nnrp1.deja.com>, Ted Dennison wrote: > In article <85nqaf$95o$1@nnrp1.deja.com>, > Jeff Carter wrote: > > In article <85ngl3$10s$1@nnrp1.deja.com>, > > Ted Dennison wrote: > > > First you interface to the routine to create your thin binding: > > > > > > function esGetValue (Key : in Interfaces.C.Int; > > > Value : in System.Address > > > ) return Interfaces.C.Int; > > > pragma Import (C, esGetValue, "esGetValue"); > > There's no reason to use System.Address here. Use an access parameter: > > If you mean doing a "Value : access Interfaces.C.Int", that is sometimes > doable. The problem with that is than many C interfaces, particularly > system calls, have optional pointer parameters where "null" is an > acceptable value. An access parameter does not allow "null" to be passed > in. So in general they aren't always useful This is sometimes the case, though it doesn't appear to be so here. When it is the case, and you want to pass null, use an access type type Int_Ptr is access all Interfaces.C.Int; ... Value : in Int_Ptr; -- in function specification ... Value => null -- in function call System.Address loses all type checking. You can pass the address of _anything_. An access parameter or access type limits you to the address of something of the correct type. System.Address is best used when the type is unknown, such as "void*". -- Jeff Carter "Now go away or I shall taunt you a second time." -- Monty Python and the Holy Grail Sent via Deja.com http://www.deja.com/ Before you buy.