Subject: Re: Fixing pointer-to-int casts
To: Johnny C. Lam <lamj@stat.cmu.edu>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-alpha
Date: 05/16/1998 08:18:52
On Sat, 16 May 1998 01:09:28 -0400
"Johnny C. Lam" <lamj@stat.cmu.edu> wrote:
> I've been making some of the packages in the pkgsrc tree and the xsrc
> tree, and I get quite a few of the the following warnings:
>
> warning: cast from pointer to integer of different size
> warning: cast to pointer from integer of different size
>
> What is the best way to fix up the code? Is there a way to avoid
> sprinkling #ifdef's into the code to differentiate between 32-bit and
> 64-bit platforms, like replacing ints with longs?
A lot of the time this can happen like e.g.:
char *foo = inet_ntoa(bar);
...and the prototype for inet_aton() isn't in scope, thus causing the
warning because functions implicitly return int unless otherwise specified.
> How was this fixed in the MI NetBSD source when the Alpha port got
> committed?
It depends on the circumstance... if it's a case of a pointer being cast
to or stored in an integral type, it needs to be a long or a u_long. Other
times it was an issue of getting prototypes in scope...
Jason R. Thorpe thorpej@nas.nasa.gov
NASA Ames Research Center Home: +1 408 866 1912
NAS: M/S 258-5 Work: +1 650 604 0935
Moffett Field, CA 94035 Pager: +1 650 428 6939