| View previous topic :: View next topic |
| Author |
Message |
KaylaKaze
Joined: 05 May 2004 Posts: 75 Location: NC, USA
|
Posted: Mon Dec 06, 2004 2:58 am Post subject: u8 / char conversion problems |
|
|
| 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. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Dec 06, 2004 3:32 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
chp
Joined: 23 Jun 2004 Posts: 313
|
Posted: Mon Dec 06, 2004 4:09 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
KaylaKaze
Joined: 05 May 2004 Posts: 75 Location: NC, USA
|
Posted: Mon Dec 06, 2004 4:41 am Post subject: |
|
|
| 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++ |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Mon Dec 06, 2004 11:23 am Post subject: |
|
|
Cant you just cast from signed -> unsigned??
| Code: | u8 a = 42;
char b = (char)a;
b = 37;
a = (u8)b;
|
seems to work for me, and not too mush hassle... _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
KaylaKaze
Joined: 05 May 2004 Posts: 75 Location: NC, USA
|
Posted: Mon Dec 06, 2004 2:47 pm Post subject: |
|
|
| 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). |
|
| Back to top |
|
 |
Raizor
Joined: 18 Jan 2004 Posts: 60 Location: out there
|
Posted: Mon Dec 06, 2004 9:09 pm Post subject: |
|
|
| karma... |
|
| Back to top |
|
 |
blackdroid
Joined: 17 Jan 2004 Posts: 564 Location: Sweden
|
Posted: Tue Dec 07, 2004 6:09 pm Post subject: |
|
|
Hahaha :) you mean you reap what you sow ? ;) _________________ Kung VU |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Wed Dec 08, 2004 3:34 am Post subject: |
|
|
...whore! _________________ "He was warned..." |
|
| Back to top |
|
 |
|