• entries
557
1237
• views
423365

# Untitled

96 views

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*

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.

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...

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]

A static cast would probably take care of that compile error. GCC acts very strange around unsigned char and normal char literals, too.

## Create an account

Register a new account