comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Interfaces.C.Strings
Date: Mon, 03 Jun 2002 19:09:15 GMT
Date: 2002-06-03T19:09:15+00:00	[thread overview]
Message-ID: <3CFBBED4.AF42C592@acm.org> (raw)
In-Reply-To: adfjbg$gec$1@upsn21.u-psud.fr

Philippe Tarroux wrote:
> 
> This function returns a Chars_Ptr (Char *) type which is a pointer to a
> char_array supposed to be nul terminated. In the present case, this array
> contains pixel values and probably several nul values. The array I get from
> the Interfaces.C.Strings.Value procedure is truncated to the first nul and I
> was unable to find a way to bypass this limitation.

The main problem here is that "char*" means a lot of different things in
C, and some of them have nothing to do with characters or strings. This
function is an example of that. The return value is a pointer to an
array of what are referred to in Ada as Storage_Elements (type
System.Storage_Elements.Storage_Element), usually bytes, not to a
NUL-terminated string. Thus, using Value is probably inappropriate,
although a version of Value that takes a Length parameter may do what
you want.

In general, though, you might want to define a C-convention access type
designating System.Storage_Elements.Storage_Array (or even better a
suitably constrained subtype) and import a function returning that
access type.

-- 
Jeff Carter
"Nobody expects the Spanish Inquisition!"
Monty Python's Flying Circus



      parent reply	other threads:[~2002-06-03 19:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-01 12:34 Interfaces.C.Strings Philippe Tarroux
2002-06-03 16:22 ` Interfaces.C.Strings sk
2002-06-03 19:09 ` Jeffrey Carter [this message]
replies disabled

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