Untitled

posted in DruinkJournal
Published December 19, 2006
Advertisement
Good one, CodeWarrior:
Quote:Warning : implicit arithmetic conversion from 'int' to 'unsigned char'
gaSimulationTrackSel.cpp line 468 >setSuperPaletteOfs(m_pTopMap->getSuperPaletteOfs() == 0 ? 8 : 0);
getSuperPaletteOfs() returns an unsigned char.

WHERE, CODEWARRIOR? WHERE IS THE INT? I SEE NO INTS?
Solution:
m_pTopMapNext->setSuperPaletteOfs((u8)(m_pTopMap->getSuperPaletteOfs() == 0 ? 8 : 0));	// Shut the f*** up, Codewarrior



*gets back to work*
Previous Entry Untitled
Next Entry Untitled
0 likes 4 comments

Comments

jollyjeffers
Seems fairly straight-forward (in a twisted compiler-error sort of way) to me [razz]

The numerical literals (0, 8) are assumed to be 'int' even though there shouldn't be any problem converting them to 'unsigned char'. Or something like that - the literals being the problem and not the function call.
December 19, 2006 09:04 AM
Evil Steve
Quote:Original post by jollyjeffers
Seems fairly straight-forward (in a twisted compiler-error sort of way) to me [razz]

The numerical literals (0, 8) are assumed to be 'int' even though there shouldn't be any problem converting them to 'unsigned char'. Or something like that - the literals being the problem and not the function call.
But then you shouldn't be able to do unsigned char p = 42;. I'm just going to fight CodeWarrior...
December 19, 2006 09:32 AM
Pouya
That seems like a normal warning. Of course you see ints, you have the 8 and 0 in there.

Though, most compilers are smart enough to compile an integral literal the correct way, so when you do char x=8 and int x=8, they would recognize the 8's as different binary representations. I guess CodeWarrior is not one of them [grin]
December 19, 2006 12:26 PM
Ravuya
A static cast would probably take care of that compile error. GCC acts very strange around unsigned char and normal char literals, too.
December 19, 2006 12:37 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement