comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: win32ada design question/problem
Date: 1998/11/17
Date: 1998-11-17T00:00:00+00:00	[thread overview]
Message-ID: <72shhh$8cg$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 36519A6A.C07508F5@elca-matrix.ch

In article <36519A6A.C07508F5@elca-matrix.ch>,
  Mats.Weber@elca-matrix.ch wrote:
> dennison@telepath.com wrote:
> >
> > In article <ubtm7cxj0.fsf@gsfc.nasa.gov>,
> >   Stephen Leake <Stephen.Leake@gsfc.nasa.gov> wrote:
> > >
> > > While I agree it wasn't well designed, I don't agree you need to go to
> > > a thick binding. The binding should use 'out' parameter modes in the
> > > places where C uses pointers to achieve output parameters. Most
> > > compilers will map an 'out' parameter to a C pointer, since that's
> > > what 'by reference' means.
> >
> > Actually, according to B.3(68), that is *required* behavour. The problem
with
> > that technique is that many C routines attach a signifigance to a incomming
> > value of null. You won't be able to produce such a value on the Ada side, so
> > some of the functionality of the C routine will be lost.
>
> And there is another, more severe problem. The C function may allocate
> some memory that you must free later, e.g.
>
> procedure P (X : out Some_Record_Type);
> pragma Import(C, P);
>
> now as you have no pointer to the returned data, you cannot free it.
>
> I think the Ada 83 classic int + System.Address approach is better in
> this case.
>

I'm trying to write some portable bindings to the Zlib compression library
right now, and have found myself reverting to just that. But are there
portability issues associated with System.Address? My reading of 13.7 is that
System.Address does not nessecarily map to a C pointer, and that
System.Null_Address does not nessecarily map to a C null pointer.

The "portable" alternative we are given is Interfaces.C.Pointers. But its a
real pain to use for routines where the input object could be any type.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1998-11-17  0:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-13  0:00 win32ada design question/problem Mats Weber
1998-11-13  0:00 ` Tom Moran
1998-11-16  0:00   ` Mats Weber
1998-11-18  0:00     ` Tom Moran
1998-11-18  0:00       ` dennison
1998-11-19  0:00       ` Mats Weber
1998-11-19  0:00         ` dennison
1998-11-19  0:00           ` David Botton
1998-11-19  0:00         ` David Botton
1998-11-19  0:00           ` Mats Weber
1998-11-23  0:00             ` Marin David Condic
1998-11-19  0:00       ` Mats Weber
1998-11-27  0:00     ` Roga Danar
1998-11-13  0:00 ` dennison
1998-11-16  0:00   ` Stephen Leake
1998-11-16  0:00     ` Tucker Taft
1998-11-17  0:00     ` dennison
1998-11-17  0:00       ` Mats Weber
1998-11-17  0:00         ` dennison [this message]
1998-11-17  0:00           ` Mats Weber
1998-11-17  0:00           ` Tucker Taft
1998-11-18  0:00             ` Tom Moran
1998-11-18  0:00               ` dennison
  -- strict thread matches above, loose matches on Subject: below --
1998-11-19  0:00 tmoran
1998-11-19  0:00 ` dennison
1998-11-19  0:00   ` Tom Moran
1998-11-20  0:00     ` dennison
1998-11-20  0:00       ` Tom Moran
1998-11-23  0:00     ` Marin David Condic
1998-11-23  0:00       ` Mats Weber
1998-11-24  0:00         ` dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox