Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] What does this gcc compiler warning mean?

2006-02-27 by Reza

--- kc9dag <dpboyer@dnadepictions.com> wrote:

> I am getting:
> wirelessmouse.c:213: warning: comparison is always
> true due to limited
> range of data type
> 
> for the line:
> if ((byte_index >=0) && (byte_index < 8))
> 
> where byte_index is delared as:
> unsigned char byte_index;
> 
> 
> This was taken from someone elses "working" code,
> but I have just
> spent the past 4 hours rewriting large sections
> because they simply
> would not compile (it said that it was written for
> winavr, but I'm
> thinking that it must have been for a different
> compiler due to all
> the syntax errors.)  I have finally gotten it to
> compile but I have
> several of these identical warnings remaining.
> 
> Someone please help me,
>     Daniel
> 
> 
> 
> 
> 

maybe the statement is ok, but there is a small
problem:

<unsigned char> is unsigned, so following condition is
always true:

(byte_index > 0)

to avoid warning, use this statement instead:

if( byte_index < 8 )

actuall 0 is always less than 8, and <unsigned char>
value could not be less than zero.

good luck;


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.