comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Ada array vs C pointer (call by reference)
Date: Mon, 30 Jun 2008 10:13:30 -0700 (PDT)
Date: 2008-06-30T10:13:30-07:00	[thread overview]
Message-ID: <e2c1ab35-55c8-4873-afcd-ee27bdbbd36a@i36g2000prf.googlegroups.com> (raw)
In-Reply-To: wccvdztphv0.fsf@shell01.TheWorld.com

On Jun 28, 10:52 am, Robert A Duff <bobd...@shell01.TheWorld.com>
wrote:
> Adam Beneschan <a...@irvine.com> writes:
> > On Jun 27, 3:14 pm, Keith Thompson <ks...@mib.org> wrote:
> >> It doesn't *mandate* the representation used by the C compiler; the
> >> author of the Interfaces.C implementation has to *know* the
> >> representation used by the C compiler.
>
> > Which is, of course, impossible without a crystal ball.
>
> No need for crystal balls.  Just read the documentation of the C
> compiler.

What do you mean by "the" C compiler?  My impression was that more
than one C compiler exists in the world.  And even for particular
target architectures, more than one C compiler exists for many of
these.  How is the Ada compiler supposed to know which one you're
using, without a crystal ball?  I get the impression that Adrian is
faced with that sort of problem; Maciej also mentioned this, and also
mentioned the real possibility that even one C compiler could use
differing representations for floats or other data types depending on
command-line flags.

I'm probably pretty confused here---I don't even know what we're
arguing about any more, and I could well be overinterpreting what some
people are saying.  Some people seem to think the Ada compiler will
know how the C compiler works, and some seem to go far enough to say
that the Ada compiler should be able to *guarantee* that types in
Interfaces.C will have the same representation, and that the RM
requires this.  I don't think that makes any sense.  Others have
seemed to imply that since multiple C compilers exist and that Ada
won't know for sure which one is being used, it's pointless to use
Interfaces.C; I don't think that makes sense either.  My
interpretation is that an Ada compiler vendor should know what the
data representations are for the *typical* C compiler used in the
typical fashion on that system (which may well be a C compiler made
available by the same vendor, or a related one), and should make
things so that Interfaces.C will work with that.  But since there's no
guarantee that any particular object file or library will have been
compiled with that C compiler, that's the most any Ada compiler can
do.

I also don't think there's any requirement for Ada to dig around
external files to figure out what the representations are.  I checked
a C book we had lying around, and while it gave no specific definition
for the representations of "int", "float", etc., it did say that the
boundaries of those types are available in <limits.h>.  This is (or
was) apparently part of the ANSI standard.  Does this mean that an Ada
compiler has to read <limits.h> [assuming it knows what the default
#include directory is] to find information about the types used by the
C compiler?  I really, really do not think there is any such RM
requirement.


> This whole argument started because somebody wanted to use Float instead
> of C_Float.  But there is nothing in the Ada RM saying that Float should
> correspond to anything in particular.  There IS something in the RM
> saying that C_Float corresponds to float as implemented by the C
> compiler(s) that the Ada compiler claims to support interfacing to.
> And the Ada compiler documentation will tell you which C compiler(s)
> are supported.

Yeah, I think those last two sentences are the key here.

                             -- Adam




  reply	other threads:[~2008-06-30 17:13 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 [this message]
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