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,32d4b7099c3e0137 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-20 18:17:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!newsfeed2.earthlink.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3E2CAD93.6050502@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C code to Ada References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 21 Jan 2003 02:17:09 GMT NNTP-Posting-Host: 63.184.17.66 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1043115429 63.184.17.66 (Mon, 20 Jan 2003 18:17:09 PST) NNTP-Posting-Date: Mon, 20 Jan 2003 18:17:09 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:33264 Date: 2003-01-21T02:17:09+00:00 List-Id: James S. Rogers wrote: > I looked in the GNAT file i-cstrea.ads. It defines the following > (just an excerpt from the file) > > subtype voids is System.Address; > -- Corresponds to the C type void* > > It appears that you can correctly use System.Address on to > bind to a C void*. In C, "pointer" and "address" are used interchangeably, so you can generally use System.Address for any C pointer. You can also do something like type Void_Ptr is access all Integer; pragma Convention (C, Void_Ptr); and use Void_Ptr for void*. Integer is just a placeholder; it doesn't matter what the type designates, since you're never going to dereference values of the type, just get them from and pass them to C functions (sort of like private types). This has the advantage that Void_Ptr has the form of a C pointer even if System.Address doesn't. If you like things a little thicker, you can define type Handle is private; private type Handle is access all Integer; pragma Convention (C, Handle); and use Handle for void*. -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus