forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

u8 / char conversion problems

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Dec 06, 2004 2:58 am    Post subject: u8 / char conversion problems Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Guest






PostPosted: Mon Dec 06, 2004 3:32 am    Post subject: Reply with quote

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

PostPosted: Mon Dec 06, 2004 4:09 am    Post subject: Reply with quote

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
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Dec 06, 2004 4:41 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Mon Dec 06, 2004 11:23 am    Post subject: Reply with quote

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
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Dec 06, 2004 2:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Raizor



Joined: 18 Jan 2004
Posts: 60
Location: out there

PostPosted: Mon Dec 06, 2004 9:09 pm    Post subject: Reply with quote

karma...
Back to top
View user's profile Send private message
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Tue Dec 07, 2004 6:09 pm    Post subject: Reply with quote

Hahaha :) you mean you reap what you sow ? ;)
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Dec 08, 2004 3:34 am    Post subject: Reply with quote

Raizor wrote:
karma...


...whore!
_________________
"He was warned..."
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group