>On 4 Mar 2015, Junio C Hamano Wrote:
> Sent: March 4, 2015 5:11 PM
> To: Ben Walton
> Cc: [email protected]
> Subject: Re: [PATCH] Use unsigned char to squash compiler warnings
>
> Ben Walton <[email protected]> writes:
>
> > On Mon, Mar 2, 2015 at 8:30 PM Junio C Hamano <[email protected]>
> wrote:
> >
> >> The conversion looked good from a cursory view; I didn't check it
> >> very carefully though.
> >>
> > Yes, because of the Solaris ABI, the Studio compiler defaults char to
> > signed char.
>
> Doesn't our beloved GCC also uses signed char when you write char?
> You keep saying that "defaults to signed char is the problem", but that
does not
> explain why those in the rest of the world outside the Solaris land do not
> encounter this problem.
>
> $ cat >x.c <<\EOF
> #include <stdio.h>
> int main (void) {
> SIGNED char ch = 0xff;
> printf("%d\n", ch);
> return 0;
> }
> EOF
> $ gcc -Wall -DSIGNED= x.c && ./a.out
> -1
> $ gcc -Wall -DSIGNED=signed x.c && ./a.out
> -1
>
> I think th problem is not Solaris uses signed char for char like everybody
else
> does ;-) but it gives a fairly useless warning to annoy people.
>
> In any case, here is what I queued, FYI, on bw/kwset-use-unsigned topic.
Even the NonStop c99 compiler does not report a warning - and it is usually
very noisy. The default is unsigned char for c99 on this platform, and the
value interpretation is significant.
#include <stdio.h>
int main (void) {
char ch0 = 0xff;
signed char ch1 = 0xff;
unsigned char ch = 0xff;
printf("%d, %d, %d, %d, %d\n", ch0, ch, ch1, ch==ch0, ch==ch1);
return 0;
}
255, 255, -1, 1, 0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html