comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: C code to Ada
Date: Tue, 21 Jan 2003 02:17:09 GMT
Date: 2003-01-21T02:17:09+00:00	[thread overview]
Message-ID: <3E2CAD93.6050502@acm.org> (raw)
In-Reply-To: j8%W9.4814$zF6.411089@bgtnsc04-news.ops.worldnet.att.net

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




  parent reply	other threads:[~2003-01-21  2:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-20 18:44 C code to Ada chris.danx
2003-01-20 21:33 ` sk
2003-01-20 21:43   ` chris.danx
2003-01-20 22:56     ` James S. Rogers
2003-01-20 23:05       ` chris.danx
2003-01-21  2:17       ` Jeffrey Carter [this message]
2003-01-20 23:32     ` sk
2003-01-21  0:56       ` chris.danx
2003-01-21  1:26         ` sk
2003-01-21 15:49           ` Frank J. Lhota
2003-01-22  1:05           ` chris.danx
2003-01-21  2:27   ` Jeffrey Carter
2003-01-21  2:55     ` sk
2003-01-21 19:33       ` Jeffrey Carter
2003-01-21  6:18     ` Simon Wright
     [not found] ` <3E2C6B2B.5090600@noname.com>
2003-01-20 21:39   ` sk
2003-01-21  1:23 ` sk
2003-01-25 21:28   ` chris.danx
2003-01-26  2:16     ` sk
2003-01-26  3:04     ` sk
     [not found]     ` <3E33502D.7030503@noname.com>
2003-01-26  5:37       ` sk
2003-01-23  8:00 ` sk
2003-01-24 18:03   ` chris.danx
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox