From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5a84d5077c54a29d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 28 Jun 2008 00:00:05 +0200 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada array vs C pointer (call by reference) References: <5df91e99-a972-48f7-b466-3eb05dc0a915@m3g2000hsc.googlegroups.com> <4864fc92$0$6617$9b4e6d93@newsspool2.arcor-online.net> <873f013b-c7eb-4cab-ade7-7b31503baa8b@c58g2000hsc.googlegroups.com> In-Reply-To: <873f013b-c7eb-4cab-ade7-7b31503baa8b@c58g2000hsc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <486562e9$0$6554$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 28 Jun 2008 00:00:09 CEST NNTP-Posting-Host: 1ab2260e.newsspool3.arcor-online.net X-Trace: DXC=XXCgdc`9B;G=8m7nZkdN^@McF=Q^Z^V3H4Fo<]lROoRA8kFejVH0<[X^1Zg>Y@E^\g@fFV?kH X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:924 Date: 2008-06-28T00:00:09+02:00 List-Id: Maciej Sobczak wrote: > On 27 Cze, 16:43, Georg Bauhaus 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