cancel
Showing results for 
Search instead for 
Did you mean: 

Unsigned char is always true ?

antonius
Senior
Posted on October 10, 2015 at 03:06

Guys,

What should I change for fixing :

Warning : comparison of constant 49152 with expression of type ''unsigned char'' is always true ....?

the line is :

while(Mp3ReadRegister(0x03) != CLOCK_REG)

....

unsigned char Mp3ReadRegister( unsigned char addressbyte)

#define CLOCK_REG       0xc000

Thanks

2 REPLIES 2
markb
Associate II
Posted on October 10, 2015 at 10:50

Mp3ReadRegister() returns an 8 bit value which (when zero-extended) to int (32 bits) will have 24 zero most significant bits so the value can never be equal to 0xc000. Perhaps you need to shift either the function return value or the constant?

Posted on October 10, 2015 at 16:47

So is CLOCK_REG the content of the register? If the registers are 16-bit wide you'd probably want to do the comparison as such.

The compiler just figured out your two numbers can never be the same, so the inequality is always true.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..