From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,f9bcef78c4b3c0ab X-Google-Attributes: gid109fba,public X-Google-Thread: fee84,f9bcef78c4b3c0ab X-Google-Attributes: gidfee84,public X-Google-Thread: 1164f8,f9bcef78c4b3c0ab X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-03-23 09:08:09 PST Xref: gmd.de comp.unix.osf.osf1:2645 comp.sys.dec:14583 comp.lang.c++:50206 Newsgroups: comp.unix.osf.osf1,comp.sys.dec,comp.lang.c++ Path: gmd.de!newsserver.jvnc.net!yale.edu!yale!gumby!newsxfer.itd.umich.edu!sol.ctr.columbia.edu!howland.reston.ans.net!torn!watserv2.uwaterloo.ca!undergrad.math.uwaterloo.ca!math.uwaterloo.ca!tromp From: tromp@math.uwaterloo.ca (John Tromp) Subject: Re: Comparing 64-bit pointers with Alpha cxx Message-ID: Sender: news@undergrad.math.uwaterloo.ca (news spool owner) Organization: University of Waterloo References: Date: Wed, 23 Mar 1994 17:08:09 GMT In article , coates@kelvin.physics.uq.oz.au (Tony Coates) writes: > We have just received the DEC cxx compiler for our AXP (Alpha) running > OSF/1.3. We don't have the printed documentation for it yet, > unfortunately. I am having a problem, because I need to compare two > pointers. It appears that cxx, like the DEC c89 C compiler, doesn't > support 64-bit integer data types, for some arcane reason. And, > unfortunately, the pointer comparison (<) seems to first require an > implicit conversion to an integer type. So, I am getting warmings > about conversion of pointers to a type which is too small, which I > consider a pretty serious warning. > Can anyone give me a hint as to how one can compare 64-bit > pointers, or how to avoid this implicit conversion to integer? I > would be really grateful for any hints at all that anyone can give to > me. You can compare pointers in C, but only if they "live" in the same area of allocated memory. Arbitrary pointer comparisons may not make sense in some odd segmented architecture, hence the restriction. So, assuming the space you allocated is in fact no greater than 2^32 bytes, and that the pointers are of the same type, then the proper conversion is to subtract the base address of that space, and this gives you an integer that fits. However, this should not be necessary, and the compiler should allow straight comparison between the pointers. If the pointers are of different types, then I suggest you cast them to the same type (e.g. char *) before the subtraction. Hope this helps. regards, %!PS % -John Tromp (tromp@math.uwaterloo.ca) 42 42 scale 7 9 translate .07 setlinewidth .5 setgray/c{arc clip fill setgray}def 1 0 0 42 1 0 c 0 1 1{0 3 3 90 270 arc 0 0 6 0 -3 3 90 270 arcn 270 90 c -2 2 4{-6 moveto 0 12 rlineto}for -5 2 5{-3 exch moveto 9 0 rlineto}for stroke 0 0 3 1 1 0 c 180 rotate initclip}for showpage