comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Ada array vs C pointer (call by reference)
Date: Sat, 28 Jun 2008 07:11:33 -0700 (PDT)
Date: 2008-06-28T07:11:33-07:00	[thread overview]
Message-ID: <72661814-9e6e-40bb-a013-ad3b5c7217dc@59g2000hsb.googlegroups.com> (raw)
In-Reply-To: 48658c46$0$2689$4d3efbfe@news.sover.net

On 28 Cze, 02:56, "Peter C. Chapin" <pcha...@sover.net> wrote:

> My understanding is that the interfacing to C is only really meaningful
> if the Ada compiler is in some way associated with a corresponding C
> compiler (for example, created by the same vendor).

This is exactly my point.

We have to rely on some external knowledge, which is provided by
compiler vendors. Or sometimes by just old good common sense.
In any case, there is nothing related to "portability" in
Interfaces.C. The types defined there are exactly as non-portable  (as
far as interfacing is concerned) as any other type in Ada, because the
other side is a moving target. And if some vendor gives guarantees
about any type, these guarantees are out of scope of AARM and can be
also given to types from other packages, including Standard. Actually,
I'd expect a quality vendor to document everything - and it is the
documentation that tells me what is compatible for interfacing and
what is not.

There is of course some added value in Interface.C.XXX - it is
documenting the intent. If I see something like:

procedure Foo (X : in Interfaces.C.int);

then I understand that the intent is to interface with some C code. I
will also expect some pragma Import/Export in the next line, and so on
- this is exactly the purpose of documenting the intent. I might not
have the same understanding with Integer as the parameter type, even
though there is nothing technical that guarantees compatibility with
Interfaces.C.int or prohibits it with Integer.

> However, when I call C code compiled with gcc using
> GNAT, I would expect Interfaces.C to specify the right types because gcc
> and GNAT are closely related compilers.

Yes.

> Furthermore if I then move my
> Ada/C program to another Ada/C compiler suite, I would expect it to
> continue to work

Yes, but it has nothing to do with Interfaces.C itself - it is only
the matter of how the Ada/C "suite" is documented, because depending
on which types you focus on, you will get different compiler pairs in
the set.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



  reply	other threads:[~2008-06-28 14:11 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
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 [this message]
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