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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f58e3abc6790eb1b,start X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Interfaces.C.Strings.Value(Chars_Ptr,Length) Date: 1999/12/28 Message-ID: <3869160C.418977BB@telepath.com>#1/1 X-Deja-AN: 565760985 Content-Transfer-Encoding: 7bit References: X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 946410795 216.14.8.11 (Tue, 28 Dec 1999 14:53:15 EST) Organization: Telepath Systems (telepath.com) MIME-Version: 1.0 NNTP-Posting-Date: Tue, 28 Dec 1999 14:53:15 EST Newsgroups: comp.lang.ada Date: 1999-12-28T00:00:00+00:00 List-Id: Jan Kroken wrote: > I have a > > struct x { > char *dptr; > int dsize; > } > in C which I have imported into Ada with ... > return c.strings.value(d.dptr, > c.size_t(d.dsize)); > But the only thing it does is to raise an interfaces.c.terminator_error. The problem is that the Interfaces.C.Strings.Value routine works by searching through the string until it reaches a terminator. The structure you list above was clearly designed to not require a terminator. Thus it would not be shocking if the C routine that filled it in did not terminate the string. The problm you have is the definition of C.Strings.Value. It is supposed to be equivalent to C.To_Ada(C.Strings.Value(d.dptr, c.size_t(d.dsize), Trim_Nul=>True). But the definition of C.To_Ada says that if Trim_Nul is true and there is no Nul to trim, it will raise Terminator_Error. To get around the problem, try doing a C.To_Ada(C.Strings.Value(d.dptr, c.size_t(d.dsize), Trim_Nul=>False). -- T.E.D. Home - mailto:dennison@telepath.com Work - mailto:dennison@ssd.fsi.com WWW - http://www.telepath.com/dennison/Ted/TED.html ICQ - 10545591