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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news2.google.com!postnews.google.com!i36g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada array vs C pointer (call by reference) Date: Mon, 30 Jun 2008 10:13:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <5df91e99-a972-48f7-b466-3eb05dc0a915@m3g2000hsc.googlegroups.com> <3dcc4a2d-f2f9-4c98-96c8-cd9dd1b090fe@z72g2000hsb.googlegroups.com> <44b654da-5a19-4230-a5f2-94e35f2b3aeb@d19g2000prm.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1214846010 1243 127.0.0.1 (30 Jun 2008 17:13:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Jun 2008 17:13:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i36g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:959 Date: 2008-06-30T10:13:30-07:00 List-Id: On Jun 28, 10:52 am, Robert A Duff wrote: > Adam Beneschan writes: > > On Jun 27, 3:14 pm, Keith Thompson 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 . This is (or was) apparently part of the ANSI standard. Does this mean that an Ada compiler has to read [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