comp.lang.ada
 help / color / mirror / Atom feed
From: Didier Utheza <ddutheza@bu.edu>
To: Lin <lin@post.com>
Subject: Re: pointer in C & in  Ada
Date: Tue, 7 Aug 2001 19:05:04 -0400
Date: 2001-08-07T19:05:04-04:00	[thread overview]
Message-ID: <Pine.A41.4.10.10108071850200.132126-100000@acs5.bu.edu> (raw)
In-Reply-To: <86772402.0108071439.1c3e1e40@posting.google.com>

As far as C is concern I can explain the following:
		void function(argument);	is actually a function
that does not return a result. In other word a procedure.

		void *function(arguments); or void *p; are elements that
point to an undefined type.

When you declare a pointer in C, like int *point_to_int; you are stating
two related things. The type int gives you the offset (the number of
memory cells necessary to represent the data, with int let's say 4 bytes
on a 32bits machine). The actual pointer: point_to_int is
refering/pointing to the base cell of rour object (the first cell of the
four that contain your integer).

So what happens when you define your pointer as void *point_to_anything;
you have a pointer that can access any type. This is because you just
define the base cell doing so. The actual offset (given by the type) is
unknown and it your job as the programmer to let the system know about it
(in C, they use the macro function sizeof() that returns the size of the
type-argument).

About Ada95, like you I am in the vague. My guess is that it is not
possible in pure Ada, because on the constraint on type checking and that
you have to use a specific pragma such as unconstrained_checking (I do not
remember the name exactly). Good sources for such examples are the source
codes of the GUI libraries (GtkAda, JEWL,....). But I am sure that
somebody will give you an answer pretty soon.
				Didier Utheza.

On 7 Aug 2001, 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
> 
> 




  reply	other threads:[~2001-08-07 23:05 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 [this message]
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
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