comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interfacing to C without dynamic memory
Date: Fri, 14 Nov 2008 19:12:33 -0600
Date: 2008-11-14T19:12:33-06:00	[thread overview]
Message-ID: <gfl7mr$pm8$1@jacob-sparre.dk> (raw)
In-Reply-To: 491de115$0$29376$426a74cc@news.free.fr

...
> 3. Wrap imported C functions by passing to them the 'Address of T's
> instances.

You were fine up to here. But there is no reason at all to do this; you can 
use 'Access and a general access type with the appropriate convention; 
'Access and an anonymous access type, or best of all, just plain parameters 
(which will be passed by reference for routines with the C convention).

An Ada 95 or newer program that uses System.Address outside of address 
clauses is broken, IMHO. There are many safer ways to do those things. (And 
avoiding access types is good, too.)

For Claw, most of the interfaces use locally declared records with the 
StdCall convention (and all of the components defined by Win32), and usually 
normal 'in' and 'in out' parameters. The only access parameters that we used 
was in functions that modified some of their arguments (and that was only 
because of Ada's broken rule against 'in out' parameters in functions).

                                    Randy.

                                  Randy.





  reply	other threads:[~2008-11-15  1:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-14 13:58 Interfacing to C without dynamic memory Maciej Sobczak
2008-11-14 20:35 ` Damien Carbonne
2008-11-15  1:12   ` Randy Brukardt [this message]
2008-11-14 23:13 ` Robert A Duff
2008-11-15 11:52   ` Samuel Tardieu
2008-11-16 21:31     ` Maciej Sobczak
replies disabled

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