comp.lang.ada
 help / color / mirror / Atom feed
* Re: Interfaces.C.Strings.Value(Chars_Ptr,Length)
       [not found] <vhiu2l2nal0.fsf@grotte.ifi.uio.no>
@ 1999-12-28  0:00 ` Ted Dennison
  0 siblings, 0 replies; only message in thread
From: Ted Dennison @ 1999-12-28  0:00 UTC (permalink / raw)


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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-12-28  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <vhiu2l2nal0.fsf@grotte.ifi.uio.no>
1999-12-28  0:00 ` Interfaces.C.Strings.Value(Chars_Ptr,Length) Ted Dennison

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