From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f58edf3a3fc00db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-20 09:20:08 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!hermes.visi.com!news-out.visi.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Chris Newsgroups: comp.lang.ada Subject: Re: Interface to C; Storage_Error Date: Wed, 20 Dec 2000 17:05:56 GMT Organization: Deja.com Message-ID: <91qote$9cj$1@nnrp1.deja.com> References: <91ondg$lpu$1@nnrp1.deja.com> <3a409667.1742507013@paragate1> NNTP-Posting-Host: 63.164.137.27 X-Article-Creation-Date: Wed Dec 20 17:05:56 2000 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) X-Http-Proxy: 1.1 x58.deja.com:80 (Squid/1.1.22) for client 63.164.137.27 X-MyDeja-Info: XMYDJUIDenderx12 Xref: supernews.google.com comp.lang.ada:3288 Date: 2000-12-20T17:05:56+00:00 List-Id: 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/