comp.lang.ada
 help / color / mirror / Atom feed
From: "Eric G. Miller" <egm2@jps-nospam.net>
Subject: Re: Interfacing to C library...
Date: Sat, 02 Nov 2002 23:59:59 GMT
Date: 2002-11-02T23:59:59+00:00	[thread overview]
Message-ID: <pan.2002.11.03.00.04.21.535611@jps-nospam.net> (raw)
In-Reply-To: wccfzujvm21.fsf@shell01.TheWorld.com

In <wccfzujvm21.fsf@shell01.TheWorld.com>, Robert A Duff wrote:

> "Eric G. Miller" <egm2@jps-nospam.net> writes:
> 
>> Missed that addition since I was looking at a copy of original RM...
> 
> The version with all the Corrigendum AI's included is available on the
> net somewhere.  Maybe somebody can post the URL?

adaic has the new one, adahome has the old one...

>> Anyway, I don't think the C_Pass_By_Copy semantics quite work the way I
>> want them too (or, it's "kludgy").  All the "Set" routines of this C
>> library take C structs by copy while all the "Get" routines take pointers
>> and all routines return (in the function sense) a long integer status
>> code.
> 
> Don't you mean the other way around?  I mean if you're Set-ing a field,
> you would need a pointer in C.

You'd think! But it's Set-ing/Get-ing data managed by the library (in 
static C variables).  

>>...  I've found if I use access types for the "Get" routines, then I 
>> have to worry about aliasing and need to use T'Unchecked_Access or I
>> need to dynamically create the objects via "new".
> 
> You can use access parameters instead of named access types,
> and then you can say 'Access.  Either way, you better make sure the C
> code doesn't squirrel away a copy of the pointer.

The library copies data back and forth.  Presumably the "Set" routines
don't take pointers so they can't modify the caller's input structures.
The Get routines just copy data into supplied structs via the pointers.

I'm not sure I understand your statement about using access parameters
versus named access types (I'm still pretty green w.r.t. to Ada)....

Aha! I missed that you couldn't mix "in/out" w/ "access" in a subprogram
parameter list declaration/definition. Okay, definitely nicer than defining
40 access to record types...
  





  reply	other threads:[~2002-11-02 23:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-01 15:38 Interfacing to C library Eric G. Miller
2002-11-01 17:11 ` Robert A Duff
2002-11-01 17:40   ` tmoran
2002-11-02  5:10     ` Eric G. Miller
2002-11-02  6:02       ` tmoran
2002-11-02 16:10       ` Robert A Duff
2002-11-02 18:35         ` Eric G. Miller
2002-11-02 18:55           ` Robert A Duff
2002-11-02 23:59             ` Eric G. Miller [this message]
2002-11-03 16:47               ` Robert A Duff
2002-11-03 18:55                 ` Eric G. Miller
2002-11-03  9:28             ` Dale Stanbrough
replies disabled

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