* Re: Comparing 64-bit pointers with Alpha cxx
1994-03-22 20:57 Comparing 64-bit pointers with Alpha cxx Tony Coates
@ 1994-03-23 7:09 ` Andrew Myers
1994-03-23 17:08 ` John Tromp
1994-03-23 22:03 ` Gerald Feldman USG
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Myers @ 1994-03-23 7:09 UTC (permalink / raw)
In article <COATES.94Mar22155736@kelvin.physics.uq.oz.au> coates@kelvin.physics.uq.oz.au (Tony Coates) writes:
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.
The type "long" is 64 bits. The POSIX defined type "ptrdiff_t" should
be a reasonably portable thing to cast pointers to.
-- Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Comparing 64-bit pointers with Alpha cxx
1994-03-22 20:57 Comparing 64-bit pointers with Alpha cxx Tony Coates
1994-03-23 7:09 ` Andrew Myers
@ 1994-03-23 17:08 ` John Tromp
1994-03-23 22:03 ` Gerald Feldman USG
2 siblings, 0 replies; 4+ messages in thread
From: John Tromp @ 1994-03-23 17:08 UTC (permalink / raw)
In article <COATES.94Mar22155736@kelvin.physics.uq.oz.au>, 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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Comparing 64-bit pointers with Alpha cxx
1994-03-22 20:57 Comparing 64-bit pointers with Alpha cxx Tony Coates
1994-03-23 7:09 ` Andrew Myers
1994-03-23 17:08 ` John Tromp
@ 1994-03-23 22:03 ` Gerald Feldman USG
2 siblings, 0 replies; 4+ messages in thread
From: Gerald Feldman USG @ 1994-03-23 22:03 UTC (permalink / raw)
In article <COATES.94Mar22155736@kelvin.physics.uq.oz.au>, 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.
Thanks for any help in advance,
Cheers,
Tony.
--
_____________________________________________________________________________
A.B.Coates, Dept. of Physics,
The University of Queensland QLD 4072 Australia.
Email: coates@physics.uq.oz.au
Phone: (07/+617) 365-3424 Fax: (07/+617) 365-1242
Disclaimer: The University is ignorant of my
opinions, let alone guilty ...
_____________________________________________________________________________
Tony,
I just tested a short program using DEC Cxx.
#include <stdio.h>
int main()
{
printf("sizeof long%ld, sizeof int:%ld\n", sizeof(long), sizeof(int));
}
sauron:test/qar/library {898%} a.out
sizeof long8, sizeof int:4
I did test on both V2.0 system and a V1.3 system. Also, a comparison of 2
pointers should never be converted to arithmetic types. (Refer to ANSI
3.3.8). I think that the version of CXX on the V1.3 system I tested on was
the released version of DEC CXX. I do know that the version on my V2.0
system is not yet released.
--
Jerry Feldman
--
Jerry Feldman Unix Systems Group
Digital Equipment Corp. Mailstop: ZKO3-3/Y25
110 Spitbrook Rd. gaf@zk3.dec.com
Nashua, NH 03062-9987 (603)881-2970
^ permalink raw reply [flat|nested] 4+ messages in thread