Mail Archives: djgpp/1998/09/08/15:46:01
On Tue, 8 Sep 1998, Eli Zaretskii wrote:
>
> On Tue, 8 Sep 1998, Elliott Oti wrote:
>
> > allegro.h: In function `movedatal':
> > allegro.h:234: warning: cast to pointer from integer of different size
> >
> > -- I let these ride.
>
> Beware: Alpha's long is 64-bit wide whereas a pointer is 32 bits (or is it
> the other way around?), so the compiler tells you here that you are
> casting 64 bits to 32 bits, which is not a very good idea...
>
> Many programs which assume that pointers and longs are the same size
> break on Alpha (the core dump at run time).
>
The program
int main()
{ printf("\n%d %d %d", sizeof(int), sizeof(long), sizeof(void *));
}
has as output
4 8 8
Thus ints are 32-bit, longs and pointers are 64-bit. So casting the ints
to pointers was OK, but saving the contents of a pointer in an int and
reusing it later will cause a core dump. Hmmm. Didn't know that.
Cheers,
Elliott Oti
http://www.fys.ruu.nl/~oti
"Q: What did the elephant say to the naked man?
A: It's cute but can you pick up peanuts with it?"
- Raw text -