comp.lang.ada
 help / color / mirror / Atom feed
From: Duncan Sands <baldrick@free.fr>
To: comp.lang.ada@ada-france.org
Cc: Alfred Hilscher <SPAM@alfred-hilscher.de>
Subject: Re: Ada equivalent for C-pointer?
Date: Fri, 14 Jan 2005 18:00:05 +0100
Date: 2005-01-14T18:00:05+01:00	[thread overview]
Message-ID: <mailman.52.1105722023.527.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <41E7F653.2F899F47@alfred-hilscher.de>

Hi Alfred,

> I want to interface to a C-function expecting a "far *", what have I to
> pass: an "access all ..." or "System.Address"? Are there differences
> between access and address, or are their internal representations equal?
> I use GNAT 3.15p.

a System.Address is what you would expect a pointer to be: a (eg) 32 bit
number referring to a memory address, like a C pointer.  Most access types
will be the same size as, and equivalent to, a System.Address, but some
access types may be bigger ("fat pointers") because they contain some
information about what they are pointing to.  This is typical of access
to unconstrained array types for example, where the access type usually
holds a memory address and also the array bounds.  What you should do is
create an access type with convention C:

	type C_Pointer is access ...
	pragma Convention (C, C_Pointer);

Here ... is whatever it is your pointer is pointing to, or anything (eg: Integer)
if you are not actually going to dereference the pointer in your Ada program.  The
pragma makes sure that the access type is what a C program expects, basically a
System.Address.

Ciao,

Duncan.



  reply	other threads:[~2005-01-14 17:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-14 16:41 Ada equivalent for C-pointer? Alfred Hilscher
2005-01-14 17:00 ` Duncan Sands [this message]
2005-01-14 20:05   ` tmoran
2005-01-15  5:00     ` Brian May
2005-01-14 22:33 ` Keith Thompson
2005-01-14 23:03   ` Stephen Leake
2005-01-15 15:51     ` Nick Roberts
2005-01-15 18:54       ` tmoran
2005-01-16  1:43         ` Keith Thompson
2005-01-17 21:35       ` Randy Brukardt
2005-01-15  9:09 ` Martin Krischik
2005-01-15 16:03 ` Nick Roberts
2005-01-15 16:27   ` Pascal Obry
2005-01-15 16:50     ` Nick Roberts
2005-01-15 17:11       ` Simon Wright
2005-01-15 18:46         ` Nick Roberts
2005-01-15 17:49       ` Pascal Obry
2005-01-16  8:44       ` Martin Krischik
2005-01-16  9:58         ` Pascal Obry
2005-01-16 11:07           ` Martin Krischik
2005-01-16  8:36     ` Martin Krischik
2005-01-16 15:01       ` Niklas Holsti
2005-01-16 16:02         ` Martin Krischik
2005-01-17 15:33           ` Niklas Holsti
2005-01-16 20:39         ` Nick Roberts
2005-01-17 21:38     ` Randy Brukardt
2005-01-17 21:45       ` Pascal Obry
2005-01-17 13:11 ` Alfred Hilscher
2005-01-18  7:31   ` Keith Thompson
replies disabled

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