From: Jeff Carter <jrcarter001@my-deja.com>
Subject: Re: Interfacing to C non-void procedure with "out" parameters
Date: 2000/01/15
Date: 2000-01-15T00:00:00+00:00 [thread overview]
Message-ID: <85omo4$u5q$1@nnrp1.deja.com> (raw)
In-Reply-To: 85nurq$cr0$1@nnrp1.deja.com
In article <85nurq$cr0$1@nnrp1.deja.com>,
Ted Dennison <dennison@telepath.com> wrote:
> In article <85nqaf$95o$1@nnrp1.deja.com>,
> Jeff Carter <jrcarter001@my-deja.com> wrote:
> > In article <85ngl3$10s$1@nnrp1.deja.com>,
> > Ted Dennison <dennison@telepath.com> 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.
next prev parent reply other threads:[~2000-01-15 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-14 0:00 Interfacing to C non-void procedure with "out" parameters Dr Steve Sangwine
2000-01-14 0:00 ` Ted Dennison
2000-01-14 0:00 ` Jeff Carter
2000-01-14 0:00 ` Ted Dennison
2000-01-15 0:00 ` Jeff Carter [this message]
2000-01-14 0:00 ` Alain Le Guennec
2000-01-17 0:00 ` Matthew Heaney
2000-01-18 0:00 ` Dr Steve Sangwine
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox