From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada array vs C pointer (call by reference)
Date: Mon, 30 Jun 2008 14:55:31 -0400
Date: 2008-06-30T14:55:31-04:00 [thread overview]
Message-ID: <wccod5isqfw.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: e2c1ab35-55c8-4873-afcd-ee27bdbbd36a@i36g2000prf.googlegroups.com
Adam Beneschan <adam@irvine.com> writes:
> 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?
The one the compiler writer chooses to support, for interfacing.
Or more than one, if the compiler writer so chooses.
>...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?
The supported C compiler(s) should be documented. If you use some other
C compiler, you're not playing by the rules of the game.
It's the same with interfacing to hardware -- if I give you an Ada
compiler that generates code for an x86, and you try to run programs
on a SPARC, it won't work. That should not be a surprise! ;-)
>...Some people seem to think the Ada compiler will
> know how the C compiler works, ...
Yes, of course it will. It won't know how ALL C compilers in the world
work (of course), but it will know about the one (or ones) that are
supported.
>... 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.
Yes, the RM requires this. But you have to obey the Ada compiler's
documentation. If it says "compile the C part of your program with gcc
version xxx using so-and-so switches", and use some other C compiler, or
some other switches, it might not work.
> 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.
The compiler writer can read limits.h, just as well as any other
documentation.
>> 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.
OK. So what is the confusion?
- Bob
next prev parent reply other threads:[~2008-06-30 18:55 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 [this message]
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