* Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences
@ 2005-10-03 2:11 Bob Brose
2005-10-03 2:22 ` Hollis Blanchard
2005-10-03 5:07 ` Christopher Friesen
0 siblings, 2 replies; 3+ messages in thread
From: Bob Brose @ 2005-10-03 2:11 UTC (permalink / raw)
To: linuxppc-dev
I'm trying to fix some of the AX25 code in the 2.6 kernel and traced down
a problem to the use of a char var which was being assigned
the value of -1. On x86 when the var was compared to -1 it succeded but
on PPC it failed. So I tried a simple test:
main()
{
char atest;
atest=-1;
printf("%i,%X\n",atest,atest);
}
With GCC 3.3.5 on 2.6.14-rc1 x86 I get:
./atest
-1,FFFFFFFF
With GCC 3.3.5 on 2.6.14-rc1 PPC I get:
./atest
255,FF
If I change the declaration of atest to a signed char on PPC I get the
same result as x86.
Does this mean the char in x86 is signed and in PPC it's unsigned?
Has it always been thus?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences
2005-10-03 2:11 Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences Bob Brose
@ 2005-10-03 2:22 ` Hollis Blanchard
2005-10-03 5:07 ` Christopher Friesen
1 sibling, 0 replies; 3+ messages in thread
From: Hollis Blanchard @ 2005-10-03 2:22 UTC (permalink / raw)
To: Bob Brose; +Cc: linuxppc-dev
On Oct 2, 2005, at 9:11 PM, Bob Brose wrote:
> If I change the declaration of atest to a signed char on PPC I get the
> same result as x86.
>
> Does this mean the char in x86 is signed and in PPC it's unsigned?
> Has it always been thus?
Yes, and yes. If it matters to you, you should explicitly use "signed
char" or "unsigned char"...
-Hollis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences
2005-10-03 2:11 Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences Bob Brose
2005-10-03 2:22 ` Hollis Blanchard
@ 2005-10-03 5:07 ` Christopher Friesen
1 sibling, 0 replies; 3+ messages in thread
From: Christopher Friesen @ 2005-10-03 5:07 UTC (permalink / raw)
To: Bob Brose; +Cc: linuxppc-dev
Bob Brose wrote:
> Does this mean the char in x86 is signed and in PPC it's unsigned?
> Has it always been thus?
From K+R:
"Whether plain chars are signed or unsigned is machine-dependent, but
printable characters are always positive."
Chris
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-03 5:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-03 2:11 Q: signed vs unsigned char, PPC vs x86 gcc 3.3.5 compiler differences Bob Brose
2005-10-03 2:22 ` Hollis Blanchard
2005-10-03 5:07 ` Christopher Friesen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).