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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c08cfbd3f797c1c X-Google-Attributes: gid103376,public From: dewar@gnat.com Subject: Re: simple question - how to emulate void * ? Date: 1998/10/25 Message-ID: <7101bo$2sn$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 404949448 References: <9v6hGdgMLuwN-pn2-Oc41W71Dq3U9@dt182n2f.tampabay.rr.com> <362EF435.7575@ddre.dk> <70pfpm$qe5@gcsin3.geccs.gecm.com> <1104_909142646@DZOG-CHEN> <70q89d$io1$1@nnrp1.dejanews.com> X-Http-Proxy: 1.0 x3.dejanews.com:80 (Squid/1.1.22) for client 202.135.41.156 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sun Oct 25 20:23:21 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/3.0 (Win95; I) Date: 1998-10-25T00:00:00+00:00 List-Id: In article <70q89d$io1$1@nnrp1.dejanews.com>, dennison@telepath.com wrote: > In article <1104_909142646@DZOG-CHEN>, > falis@ma.aonix.com (Ed Falis) wrote: > > In OA, both System and System.Storage_Units declare "+" operators with Address > and Integer or Storage_Offset respectively. Since there are use clauses > > for both units, the compiler doesn't know how to interpret the numeric literal > "1" on the right hand side of the expression. > > > > So, eliminate one of the use clauses, or qualify the literal, e.g. Integer'(1) > or Storage_Offset'(1), and the code will compile and execute. > > > > One more poor soul burned by the evil "use" clause... That does not seem exactly fair in this case. It is a mistake in an Ada 95 compiler to provide address arithmetic in System. Yes, some compilers do this for compatibility with implementation dependent additions to their System packages for Ada 83, but it is a huge pain for Ada 95 programmers. We ran across this with the DEC version of System which also supplies address arithmetic (and lots of other stuff) in their System, and it definitely inteferes with many existing programs. The danger here is not in using a USE clause per se, but in the assumption that "use System" only gets you the stuff you see in the RM. Unfortunately, that is not necessarily the case, since implementors are allowed to add anything they like to System. In GNAT, the standard version of System that you get without doing anything special is the one in the RM. If you need an extended version of System with non-standard extensions, then you can use the GNAT pragma Extend_System, naming a package that provides the extensions. We distribute a standard package System.Aux_DEC that provides the DEC Ada 83 extensions, but additional extensions can be provided. It would for example be possible to provide a package that added the OA extensions, and this is probably easy to do. We just haven't done it because there hasn't been any demand for this (our customers are typically writing new Ada 95 programs, or porting legacy code from other than Alsys systems, or porting standard Ada code that does not use these extensions) so the issue has not arisen. Note that it is definitely good Ada practice NOT to use System dependent extensions in Ada programs. For those not allergic to use clauses, it is a bit of a pity not to allow yourself to "use system", but with compilers around that add implementation dependent stuff to System, it may cause difficulties. Note that Ada is carefully designed so that the "evil" effects of using USE in a case like this are limited to the introduction of ambiguities that are (a) clearly diagnosed by any decent compiler and (b) easily fixed, so that's not exactly so evil if you know what you are doing! Note of course that address arithmetic is something that should in any case ONLY be used by Ada programmers who know what they are doing (in practice of course, as one can tell from the somewhat distasteful subject line of this thread, distasteful because void * is in some ways a crystallization of what is wrong with C, people often try to use address arithmetic in inappropriate cases!) Robert Dewar Ada Core Technologies -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own