I have the following code
#define WIDTH 8
#define HEIGHT 8
typedef struct Point
{
char x;
char y;
} Point;
#include <stdbool.h>
bool inBounds(Point * p)
{
return p->x >= 0
&& p->x <= WIDTH
&& p->y >= 0
&& p->y <= HEIGHT;
}
When I compile this (ppu-gcc 4.1.1), I get the following warning
warning: comparison is always true due to limited range of data type
although the char range is from -127 to 127, and the WIDTH is 8, which is within the char range. I already tried explicit conversion of WIDTH to char, but still got an error.
source
share