From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Re: Ada array vs C pointer (call by reference)
Date: Sat, 28 Jun 2008 00:00:05 +0200
Date: 2008-06-28T00:00:09+02:00 [thread overview]
Message-ID: <486562e9$0$6554$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <873f013b-c7eb-4cab-ade7-7b31503baa8b@c58g2000hsc.googlegroups.com>
Maciej Sobczak wrote:
> On 27 Cze, 16:43, Georg Bauhaus <rm.tsoh.plus-
> bug.bauh...@maps.futureapps.de> wrote:
>
>>> Is there any implementation where Interfaces.C.int has different
>>> properties than Integer?
...
>> procedure Cint is
>> use Interfaces;
>> use type C.int;
>>
>> X: C.int;
>> begin
>> X := C.int'last;
>> X := X + 1;
>> end;
>
> CONSTRAINT_ERROR - overflow check failed.
> I get the same with Integer.
>
> What is the difference then?
I should have made the example adress the difference
between the Ada types Integer and C.int as a representative
of C's int behavior.
In code that uses C integers I'll see C.int used, and
hence meaningfully different types. This points me to
different behavior on the C side even when inside Ada
it makes no difference:
int inc(int x) { return x + 1; }
with Interfaces.C, Ada.Text_IO;
procedure Cint is
use Interfaces;
use type C.int;
function C_inc(X: C.int) return C.int;
pragma import(C, C_inc, "inc");
X: C.int;
begin
X := C.int'last;
X := C_inc(X);
Ada.Text_IO.Put_Line(C.int'image(X));
end;
prompt>cint
-2147483648
next prev parent reply other threads:[~2008-06-27 22:00 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-27 1:39 Ada array vs C pointer (call by reference) Adrian Hoe
2008-06-27 1:42 ` Adrian Hoe
2008-06-27 2:55 ` Adam Beneschan
2008-06-27 13:02 ` Maciej Sobczak
2008-06-27 13:15 ` Adrian Hoe
2008-06-27 14:43 ` Georg Bauhaus
2008-06-27 14:47 ` Georg Bauhaus
2008-06-27 20:35 ` Maciej Sobczak
2008-06-27 22:00 ` Georg Bauhaus [this message]
2008-06-27 22:46 ` Keith Thompson
2008-06-27 16:11 ` Keith Thompson
2008-06-27 17:00 ` Robert A Duff
2008-06-27 18:15 ` Keith Thompson
2008-06-28 14:02 ` Stephen Leake
2008-06-28 21:18 ` Keith Thompson
2008-07-03 12:44 ` Rob Norris
2008-06-27 20:44 ` Maciej Sobczak
2008-06-27 22:14 ` Keith Thompson
2008-06-27 22:36 ` Adam Beneschan
2008-06-28 14:04 ` Stephen Leake
2008-06-28 21:22 ` Keith Thompson
2008-06-30 17:13 ` Adam Beneschan
2008-06-28 17:52 ` Robert A Duff
2008-06-30 17:13 ` Adam Beneschan
2008-06-30 18:55 ` Robert A Duff
2008-07-01 21:19 ` Randy Brukardt
2008-07-01 21:19 ` Randy Brukardt
2008-06-28 0:56 ` Peter C. Chapin
2008-06-28 14:11 ` Maciej Sobczak
2008-06-28 17:49 ` tmoran
2008-06-28 21:46 ` Keith Thompson
2008-06-28 17:44 ` Robert A Duff
2008-07-01 21:10 ` Randy Brukardt
2008-06-27 18:13 ` tmoran
2008-06-27 20:49 ` Maciej Sobczak
2008-06-27 4:10 ` Jeffrey R. Carter
2008-06-27 8:22 ` Adrian Hoe
2008-06-27 15:07 ` Adam Beneschan
2008-06-27 22:54 ` Jeffrey R. Carter
2008-06-28 1:15 ` Adrian Hoe
2008-06-28 2:17 ` Adam Beneschan
2008-07-01 21:31 ` Randy Brukardt
2008-07-01 21:31 ` Randy Brukardt
2008-08-22 4:06 ` Adrian Hoe
2008-06-28 4:59 ` Jeffrey R. Carter
2008-06-29 3:48 ` anon
2008-06-28 1:21 ` anon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox