From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Passing a String to a C/C++ Subprogram (Special Case)
Date: Thu, 17 Oct 2013 11:55:17 +0200
Date: 2013-10-17T11:55:01+02:00 [thread overview]
Message-ID: <525fb3f5$0$6562$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <9ee842b6-b053-4f4e-94df-66459ec1fb7c@googlegroups.com>
On 15.10.13 23:13, Eryndlia Mavourneen wrote:
> Thanks, Jeff. This could be a good way to manage things. Unfortunately, I can not guarantee that I can perform a trim operation or that the last character is indeed not being used (for the placement of a nul).
There is, in addition, a logical bridge between the languages
in addition to the technical one:
C programmers who know the "strn..." functions of C's standard
C library will not be surprised to see a subprogram profile
involving a string that has both a char* and a size_t. (In fact,
this way of handling string data is sometimes recommended.) Then,
type My_Size_T is mod 2**Positive'Size;
procedure C_Prog (C_String : in String;
C_Size_T : in My_Size_T);
where My_Size_T reflects String's index type. It might be a slightly
more reliable approximation to what you'd write with Interfaces.*.
and Conventions applied to the types, especially in corner cases
when the string is empty, or if all components allocated are used
so that there is no room for storing a terminating '\0' in C.
There can be concerns about size_t being too different from My_Size_T
just like char'Size and Character'Size might differ. (E.g. Janus/Ada
reportedly has Positive'Size = 16 while the C compiler's size_t may
require more than 16 bits.) Sizes can be checked at compile time.
next prev parent reply other threads:[~2013-10-17 9:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 19:54 Passing a String to a C/C++ Subprogram (Special Case) Eryndlia Mavourneen
2013-10-15 20:11 ` Adam Beneschan
2013-10-15 21:02 ` Eryndlia Mavourneen
2013-10-16 7:17 ` Dmitry A. Kazakov
2013-10-16 15:14 ` Jeffrey Carter
2013-10-16 17:32 ` Martin
2013-10-16 17:42 ` Eryndlia Mavourneen
2013-10-16 17:54 ` Martin
2013-10-16 18:13 ` Eryndlia Mavourneen
2013-10-16 19:40 ` Simon Wright
2013-10-16 20:02 ` Eryndlia Mavourneen
2013-10-19 2:11 ` Randy Brukardt
2013-10-16 19:11 ` Adam Beneschan
2013-10-16 21:31 ` Martin
2013-10-16 21:41 ` Adam Beneschan
2013-10-16 23:15 ` Martin
2013-10-15 20:59 ` Jeffrey Carter
2013-10-15 21:13 ` Eryndlia Mavourneen
2013-10-15 22:19 ` Shark8
2013-10-16 0:00 ` Jeffrey Carter
2013-10-17 9:55 ` Georg Bauhaus [this message]
2013-10-16 20:17 ` sbelmont700
2013-10-16 20:48 ` Adam Beneschan
2013-10-17 13:05 ` Eryndlia Mavourneen
2013-10-17 13:58 ` sbelmont700
2013-10-17 16:28 ` Eryndlia Mavourneen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox