comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Interfaces.C.Strings.Value(Chars_Ptr,Length)
Date: 1999/12/28
Date: 1999-12-28T00:00:00+00:00	[thread overview]
Message-ID: <3869160C.418977BB@telepath.com> (raw)
In-Reply-To: vhiu2l2nal0.fsf@grotte.ifi.uio.no

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






           reply	other threads:[~1999-12-28  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <vhiu2l2nal0.fsf@grotte.ifi.uio.no>]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox