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,3ce5636289df1f84 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-07 16:05:09 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsxfer.eecs.umich.edu!news.bu.edu!acs5.bu.edu!ddutheza From: Didier Utheza Newsgroups: comp.lang.ada Subject: Re: pointer in C & in Ada Date: Tue, 7 Aug 2001 19:05:04 -0400 Organization: Boston University Message-ID: References: <86772402.0108071439.1c3e1e40@posting.google.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: news3.bu.edu 997225508 24820 128.197.153.50 (7 Aug 2001 23:05:08 GMT) X-Complaints-To: news@bu.edu To: Lin In-Reply-To: <86772402.0108071439.1c3e1e40@posting.google.com> Xref: archiver1.google.com comp.lang.ada:11548 Date: 2001-08-07T19:05:04-04:00 List-Id: 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 > >