Subject: Re: build broken at usr.bin/fstat
To: None <current-users@NetBSD.ORG, joe@js.ne.mediaone.net>
From: Ross Harvey <ross@teraflop.com>
List: current-users
Date: 07/16/1998 15:42:42
> From: Joseph Sarkes <joe@js.ne.mediaone.net>
>
> I have had this happening for a couple days, and don't see any
> reason for it, as the files haven't changed, unless an include
> file is messed up somewhere. (I suppose there could also be a
> corrupt file here, but I mention it in case somebody changed
> something that isn't quite done yet.
>
> This is on a dec alpha multia running the latest snapshot, trying
> to build -current.
>
> all ===> usr.bin/fstat
> cc -O -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -DUVM -DPMAP_NEW -c fstat.c
> cc1: warnings being treated as errors
> fstat.c: In function `main':
> fstat.c:230: warning: unsigned int format, different type arg (arg 3)
: ...
: [ more similar errors ]
OK, it's fixed. Actually, that file has been checked in five times just in
July.
I usually just fix these LP64 problems without saying anything, but since
you brought it up on the general list, it's an opportunity to preach about
LP64-safe programming. :-)
The problem:
printf("%d", sizeof something);
The compiler issues a warning in 64-bit environments, the reason
the warning doesn't always happen:
sizeof returns type size_t, which is an int in ILP32,
but a long in LP64
The possible solutions are obvious:
A. Cast to (void *) and use %p
B. Cast to (int) or (unsigned int)
C. Cast to (long) or (unsigned long) and use %ld
Ross