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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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 03:40:18 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!fu-berlin.de!news.uni-stuttgart.de!news.belwue.de!news.tesion.net!newsfeed-zh.ip-plus.net!news.ip-plus.net!not-for-mail From: twolf@acm.org (Thomas Wolf) Newsgroups: comp.lang.ada Subject: Re: Interface to C; Storage_Error Date: Wed, 20 Dec 2000 11:39:52 GMT Organization: --- Message-ID: <3a409667.1742507013@paragate1> References: <91ondg$lpu$1@nnrp1.deja.com> Reply-To: twolf@acm.org NNTP-Posting-Host: kukclu.paranor.ch X-Trace: pollux.ip-plus.net 977312209 22219 195.65.4.173 (20 Dec 2000 11:36:49 GMT) X-Complaints-To: news@ip-plus.net NNTP-Posting-Date: 20 Dec 2000 11:36:49 GMT X-Newsreader: Forte Free Agent 1.11/32.235 Xref: supernews.google.com comp.lang.ada:3281 Date: 2000-12-20T11:36:49+00:00 List-Id: On Tue, 19 Dec 2000 22:28:11 GMT, Chris wrote: > > typedef void* SRV_HANDLE; > typedef void* CTX_HANDLE; > typedef void* RSLT_HANDLE; > typedef void* FLT_HANDLE; > > int GetNextVal(SRV_HANDLE srv, RSLT_HANDLE rslt, CTX_HANDLE *ctx, > char* name, double* dbl, FLT_HANDLE flt); > >My take on it in Ada (GNAT 3.13p) is: > > type Srv_Handle is new System.Address; > -- same for the other handles > > procedure GetNextVal(Ret : out int; > Srv : Srv_Handle; > Rslt : Rslt_Handle; > Ctx : access Ctx_Handle; > Name : out chars_ptr; > Dbl : access double; > Flt : Flt_Handle); > pragma Import(C, GetNextVal); > pragma Import_Valued_Procedure(GetNextVal); > >Both Name and Dbl are supposedly set/alloc'd by the library. When I >call this, it raises Storage_Error on the library call. I am totally >stumped as to what to fix, or even where to look. Is my Ada declaration >even remotely correct? 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 **"... -- Thomas Wolf -- Dr. Thomas Wolf (twolf@acm.org)