From: Jeff Carter <jrcarter@acm.org>
Subject: Re: Access and alias
Date: 2000/04/07
Date: 2000-04-07T00:00:00+00:00 [thread overview]
Message-ID: <38ED2460.479B044C@acm.org> (raw)
In-Reply-To: 38EC8032.1284C1F0@icn.siemens.de
Alfred Hilscher wrote:
>
> Jeff Carter wrote:
> > If you have to pass null, access types (with convention C) work fine. If
> > you don't have to pass null, in out works for procedures, and access
> > parameters work for functions. All keep the type checking that addresses
> > lose:
> >
> > -- int func (int* I);
> >
> > function F1 (I : System.Address) return Int;
> > pragma Import (C, F1, "func");
> >
> > function F2 (I : access Int) return Int;
> > pragma Import (C, F2, "func");
> >
> > I : aliased Int;
> > J : Int;
> > S : String := Get;
I see I forgot to put "aliased" on the declaration of S. Sorry.
> >
> > ...
> >
> > J := F1 (I'Address); -- works as intended
> > J := F1 (S'Address); -- works as not intended
> > J := F2 (I'access); -- works as intended
> > J := F2 (S'access); -- compilation error
>
> OK. But I would do a little change:
>
> Instead of:
> function F2 (I : access Int) return Int;
> pragma Import (C, F2, "func");
>
> Would write
> type Int_Access is access all INT;
> function F2 (I : Int_Access) return Int;
> pragma Import (C, F2, "func");
>
> This avoids some problems that I had with anonymous access types.
Yes, if you have to pass null, this is the way to do it. BE sure to put
a
pragma Convention (C, Int_Access)
in there. Then you declare
P : Int_Access;
...
J := F2 (P);
and presumably the C function knows what to do with the null.
--
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail
next prev parent reply other threads:[~2000-04-07 0:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-04 0:00 Access and alias NANCY HEHIR
2000-04-04 0:00 ` Laurent Guerby
2000-04-04 0:00 ` NANCY HEHIR
2000-04-04 0:00 ` Laurent Guerby
2000-04-05 0:00 ` Alfred Hilscher
2000-04-05 0:00 ` Laurent Guerby
2000-04-05 0:00 ` Ted Dennison
2000-04-05 0:00 ` Jeff Carter
2000-04-06 0:00 ` Alfred Hilscher
2000-04-07 0:00 ` Jeff Carter [this message]
2000-04-06 0:00 ` Robert Dewar
2000-04-07 0:00 ` Jeff Carter
2000-04-06 0:00 ` tmoran
2000-04-07 0:00 ` Robert Dewar
2000-04-07 0:00 ` tmoran
2000-04-09 0:00 ` Robert Dewar
2000-04-09 0:00 ` tmoran
2000-04-10 0:00 ` Jack W. Sharer
2000-04-06 0:00 ` Robert Dewar
2000-04-05 0:00 ` Jeffrey D. Cherry
2000-04-04 0:00 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox