comp.lang.ada
 help / color / mirror / Atom feed
From: Des Walker <des.walker@amsjv.com>
Subject: Re: pointer in C & in  Ada
Date: Wed, 08 Aug 2001 10:32:05 +0100
Date: 2001-08-08T10:32:05+01:00	[thread overview]
Message-ID: <3B710715.4C213A70@amsjv.com> (raw)
In-Reply-To: 86772402.0108071439.1c3e1e40@posting.google.com

Lin wrote:
> 
> If "int *p" declares that pointer p points to integer type, then
> what's the meaning of "void *p"? How can I represent it(void *p) in
> Ada language?
> 
> Many thanks,
> Lin

Hi,

Adding to what others have said you might also want to consider in what
context you want to use the 'Ada equivalent' of the void * type.

According to the online ANSI C Rationale:
"The use of void * (``pointer to void'')  as a generic object pointer
type is an invention of the Committee.  Adoption of this type was
stimulated by the desire to specify function prototype arguments that
either quietly convert arbitrary pointers (as in fread)  or complain if
the argument type does not exactly match (as in strcmp)."

This essentially permits the compiler to avoid issuing a warning about a
type mismatch in using functions where the programmer has decided the
type doesn't matter.

In Ada getting good type definitions is a significant part of the
development process. Bypassing the use of the type information, by using
a 'generic pointer type', is sometimes counter productive for both the
code user and the compiler. You could use Ada generics to develop
templates, which can be instantiated with appropriate type information.
Or you might be able to make use of tagged types to express some
underlying relationship between the data types.

Alternatively if you are considering calling C functions from Ada then,
as someone else has pointed out, it is worth looking at the Interfaces.C
package to see what it has to offer.

	Regards
	Des Walker



  parent reply	other threads:[~2001-08-08  9:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-07 22:39 pointer in C & in Ada Lin
2001-08-07 23:05 ` Didier Utheza
2001-08-08  9:29   ` Florian Weimer
2001-08-08 14:52     ` Ted Dennison
2001-08-08 16:52       ` Florian Weimer
2001-08-09 16:54     ` Didier Utheza
2001-08-13 15:47       ` lange92
2001-08-07 23:31 ` tmoran
2001-08-08  3:14 ` DuckE
2001-08-08  9:32 ` Des Walker [this message]
2001-08-08 10:40   ` Florian Weimer
2001-08-08 18:03   ` tmoran
2001-08-08 14:59 ` Ted Dennison
2001-08-08 16:53   ` Florian Weimer
2001-08-08 18:03   ` tmoran
2001-08-08 23:29   ` Des Walker
2001-08-09 20:21     ` Florian Weimer
replies disabled

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