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-19 20:00:18 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.infoave.net!arclight.uoregon.edu!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Interface to C; Storage_Error Date: Wed, 20 Dec 2000 03:52:32 GMT Organization: Deja.com Message-ID: <91padu$572$1@nnrp1.deja.com> References: <91ondg$lpu$1@nnrp1.deja.com> NNTP-Posting-Host: 38.195.186.125 X-Article-Creation-Date: Wed Dec 20 03:52:32 2000 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; 0.6) Gecko/20001205 X-Http-Proxy: 1.1 x73.deja.com:80 (Squid/1.1.22) for client 38.195.186.125 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:3276 Date: 2000-12-20T03:52:32+00:00 List-Id: In article <91ondg$lpu$1@nnrp1.deja.com>, 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? > Other suggestions? One thing I should mention first off, is that pragma Import_Valued_Procedure is a gnat-specific pragma (borrowed from the late-great DECAda). If there is any chance at all that this code may ever be ported to a different compiler, I would stick to pragma Import. That brings me to the second issue; pragma Import does essentially the same job as pragma Import_Valued_Procedure. Check the gnat docs, but it seems wrong to me that they are being used together. As for the rest, I'd need to see at least the call that is blowing up (or is it a later use of one of the parameters that is blowing up?). The interface description of that C call would be useful too. In my experience that error is likely to occur because C (or the linkage between them) is trying to dereference a null pointer or use a numeric value as a pointer. But it could be that you are misusing a returned pointer value. It could be that you didn't properly obtain one of those handles... -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/