From: Chris <enderx12@my-deja.com>
Subject: Re: Interface to C; Storage_Error
Date: Wed, 20 Dec 2000 17:05:56 GMT
Date: 2000-12-20T17:05:56+00:00 [thread overview]
Message-ID: <91qote$9cj$1@nnrp1.deja.com> (raw)
In-Reply-To: 3a409667.1742507013@paragate1
In article <3a409667.1742507013@paragate1>,
twolf@acm.org wrote:
> Name most certainly cannot be alloc'd by that C routine (it's a
> "char *" passed by value). Your Ada interface however passes a
> "char **"...
>
> I'd start there for looking for errors. What does the spec
> (if it exists) for the C routine say about that argument? Is
> it really a "char *"? If so, change the Ada declaration to
> "Name : in chars_ptr". What does it have to point to upon entry?
> What does the routine do with the memory pointed to? (How large
> must the memory area pointed to by Name be?)
>
> If the C routine really allocs Name, the C parameter type most
> probably is "char **"...
Argh. When all else fails, RTF.H carefully. Or at least the example
code. The spec doesn't actually spell it out, but Name is supposed to
be pointing to a 255-byte array of char.
What I'd like to do is have a semi-thick binding where users of the
package get ( ... Name : out String; Val : out double; ... ). So the
trick is to get the C function to fill a buffer I allocate in Ada, then
get that into an Ada String to send back to the caller.
So my initial thought is to declare the name parameter in the C
function as "in out char_array", then the wrapper function would return
its "Name := To_Ada(Name_Char_Array);". How does this sound?
Ugh, I hate C. If I wanted to program in assembler, I'd do so.
--chris
Sent via Deja.com
http://www.deja.com/
next prev parent reply other threads:[~2000-12-20 17:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-19 22:28 Interface to C; Storage_Error Chris
2000-12-20 3:52 ` Ted Dennison
2000-12-20 8:55 ` Robert Dewar
2000-12-20 11:39 ` Thomas Wolf
2000-12-20 17:05 ` Chris [this message]
2000-12-20 23:57 ` Chris
2000-12-21 15:35 ` Thomas Wolf
2000-12-21 18:07 ` Chris
2000-12-21 3:25 ` DuckE
2000-12-21 11:38 ` Robert Dewar
2000-12-23 2:45 ` DuckE
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox