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-08 02:37:32 PST Message-ID: <3B710715.4C213A70@amsjv.com> Date: Wed, 08 Aug 2001 10:32:05 +0100 From: Des Walker Organization: Alenia-Marconi Systems X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: pointer in C & in Ada References: <86772402.0108071439.1c3e1e40@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: farwkn6911.frlngtn.gecm.com X-Trace: 8 Aug 2001 10:25:53 GMT, farwkn6911.frlngtn.gecm.com Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.238.2.15!skynet.be!dispose.news.demon.net!demon!btnet-peer0!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!farwkn6911.frlngtn.gecm.com Xref: archiver1.google.com comp.lang.ada:11592 Date: 2001-08-08T10:32:05+01:00 List-Id: 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