Page 1 of 1
u8 / char conversion problems
Posted: Mon Dec 06, 2004 2:58 am
by KaylaKaze
Why won't C++ convert between u8 and char like C does? I'm getting errors like crazy here and it's driving me nuts.
Posted: Mon Dec 06, 2004 3:32 am
by Guest
C++ does get a bit more anal retentive about some things that could be done in C. However, without source code showing your variable declarations, assignments, and the problem lines in question, its a little hard to even begin to know the source of your specific problem.
Posted: Mon Dec 06, 2004 4:09 am
by chp
Simple, u8 is 'unsigned char', while 'char' is signed by default. C++ is much less tolerant when casting between types than C (and that's a good thing!). Use s8 instead of u8 if you want to get rid of the error.
Posted: Mon Dec 06, 2004 4:41 am
by KaylaKaze
Well, I know how to get rid of the error (and managed to after a lot of messing with it). It's just changing it all that was a pain in the butt, since all the code had already been written and I was just converting it to C++
Posted: Mon Dec 06, 2004 11:23 am
by cheriff
Cant you just cast from signed -> unsigned??
Code: Select all
u8 a = 42;
char b = (char)a;
b = 37;
a = (u8)b;
seems to work for me, and not too mush hassle...
Posted: Mon Dec 06, 2004 2:47 pm
by KaylaKaze
The first time I tried casting it didn't work. Later, after getting frustrated enough, I tried again and it did. I seem to be having problems like that: code that worked fine yesterday is now all buggy and when I change a setting in my screen class, the gamepad port won't open (even though they're unconnected).
Posted: Mon Dec 06, 2004 9:09 pm
by Raizor
karma...
Posted: Tue Dec 07, 2004 6:09 pm
by blackdroid
Hahaha :) you mean you reap what you sow ? ;)
Posted: Wed Dec 08, 2004 3:34 am
by mrbrown
Raizor wrote:karma...
...whore!