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,74bc23dcb20218db X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: How to access this package written in C? Date: Mon, 26 Apr 2010 14:16:31 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4e9d2aaf-c0a6-4798-b838-8f5b7c4a39d1@k33g2000yqc.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1272305775 11892 192.74.137.71 (26 Apr 2010 18:16:15 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 26 Apr 2010 18:16:15 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:8B5cUi+rC/9k77QpZx9E8A+o1nY= Xref: g2news2.google.com comp.lang.ada:11186 Date: 2010-04-26T14:16:31-04:00 List-Id: resander writes: > On Apr 22, 10:12�pm, Keith Thompson wrote: >> There is no guarantee that an int can hold the value of an address, >> and there are common systems (including Linux systems) where it >> can't. �Worse, you're not likely to get a warning if you convert >> a pointer to int, even if there's a loss of information. Why? I'd think if int is smaller than whatever*, then a cast to int clearly deserves a warning. >> The right type for this parameter is void* (which is roughly >> analogous to Ada's System.Address). Yeah, roughly. System.Address is somewhat lower level than C's void*. > Thank you all for your concerns about using an int for passing an > address. The interface actually uses a void * (could also be char * as > that is what is needed), but I changed it for the post because I > thought an all-int interface would be easier to handle at the Ada-to-C > boundary. That seems to have backfired! You should look at section B (especially B.3) of the Ada RM. There's a type char_star you can use. There's no void_star. I'm not sure why -- probably this part of Ada predates void* in C, and nobody bothered to upgrade Ada to match the new C. > Q1. > Addresses are not negative. How do I output a System.Address? In GNAT, there is a function System.Address_Image. Look at the file s-addima.ads in your GNAT distribution. Beware: this is not portable to other Ada compilers. - Bob