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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8b0d028e57f221d4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-06 09:25:51 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!pln-e!extra.newsguy.com!lotsanews.com!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail From: "Warren W. Gay VE3WWG" 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: Trying to import a C function References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 06 Nov 2003 12:11:16 -0500 NNTP-Posting-Host: 198.96.223.163 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1068138645 198.96.223.163 (Thu, 06 Nov 2003 12:10:45 EST) NNTP-Posting-Date: Thu, 06 Nov 2003 12:10:45 EST Organization: Bell Sympatico Xref: archiver1.google.com comp.lang.ada:2155 Date: 2003-11-06T12:11:16-05:00 List-Id: Steve wrote: > "Preben Randhol" wrote in > message > news:slrnbqk7aq.q3.randhol+valid_for_reply_from_news@kiuk0156.chembio.ntnu.no... > >>Hi > > [snip] > >>Now what is the equivalent of unsigned long long int in Ada? > > In GNAT on x86: > > unsigned long long = Interfaces.Unsigned_64 > > You could define your own using a modular type definition, but isn't that > the reason the Interfaces module is there in the first place? > > Steve > (The Duck) I find that it is generally easier, and more portable, to handle macros and size differences in a C wrapper function. This particularly applies to Linux, since so much changes there still. If you enforce a parameter size of 64 bits between your C wrapper and the Ada code, you can always be assured that you won't get burned on the size differences. Furthermore, if you are targeting multiple platforms/UNIces, then the structure definition, its padding and alignment will also give you trouble (and in fact this can potentially be the case with different Linux releases/distros). For this reason, it is sometimes better to have the C wrapper take the structure elements and pass them back to Ada in safe sized arguments individually (or perhaps stable structure definitions that guarantee sizes and alignments). If you use the C wrapper approach, you have a better chance of only visiting that code once. If you choose to avoid the wrapper, you'll likely be looking at the interface again, with the next release or platform. ;-) The only other alternative is to run a process that generates the interface (or interface parameters) prior to compiling. I believe that FLORIST does something along this line (but it has been a while since I have looked at that side of things). -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg