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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d9e66bfe9beb10b9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 27 Jul 2004 21:42:50 -0500 Date: Tue, 27 Jul 2004 22:42:49 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C array to ada record interface References: <87d62imomb.fsf@insalien.org> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0ZudnShYIIM3j5rcRVn-uA@comcast.com> NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-69sLKL9EBvFMNkqkBNGzF8i15JyMdZayeGuhIM24psgGlZQXtvoPXH82lsTmKGCck/YgaU4WMAv9aIL!kg2zKha4TuwcHGUZxV6GUgU5eaYiJdEGMp3H1qONbHX4H4M6PvBibrmu7cq/QA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.13 Xref: g2news1.google.com comp.lang.ada:2431 Date: 2004-07-27T22:42:49-04:00 List-Id: tmoran@acm.org wrote: > package B_Ptr_Conversion is new System.Address_To_Access_Conversions(B); > subtype B_Ptr is B_Ptr_Conversion.Object_Pointer; > which works on three different compilers. But neither > > pragma Convention (C, B_Ptr); > nor > pragma Convention (C, B_Ptr_Conversion.Object_Pointer); > is then legal. That is correct, see the limitations on where representation pragmas can appear in RM 13.1 as ammended. (The wordsmithing in the 2000 Ammendment in this area is extensive, but I don't think it affected this issue one way or the other.) > The program works without the pragma Convention on all three Ada compilers > I tried, but it's not clear to me that's guaranteed to be OK, and if some > system does need the pragma, is there a compiler-agnostic way to solve > this problem? No! But remember here that what can't be compiler agnostic is the choice of C compiler and options to match the Ada compiler (and options). If the Ada compiler uses the same type of addresses as the C compiler there is no problem. But if you have a 64-bit Ada compiler and a 32-bit C compiler (or vice-versa) it can't work. Well, not quite, but you know what I mean. For example, with the new AMD64 chips--including Intel's newest Xeon--you can have a library that is compiled for IA-32, and another library compiled in long mode, and the hardware will convert the addresses if possible on the calls and returns so that a program can use either one. But you can't link 32-bit code and long mode code into the same executable, you have to use .dlls. The best you can do is to specify the sizes of the addresses, so that the compiler will reject your program if they don't match. In fact a better example of why this is an insoluble problem is that the new Xeon (Nocona) does not have an IOMMU, while the Opteron and Athlon64 use the CPU's MMU for all memory references. The net effect is that I/O drivers have to be written differently for the two families. There is no magic wand that either a C compiler or an Ada compiler can wave to fix that semantic mismatch. -- Robert I. Eachus "The flames kindled on the Fourth of July, 1776, have spread over too much of the globe to be extinguished by the feeble engines of despotism; on the contrary, they will consume these engines and all who work them." -- Thomas Jefferson, 1821