'comparison is always true due to limited range of data type' warning in C?

后端 未结 6 1321
一向
一向 2021-01-12 10:22

I have the following code

//Point.h
#define WIDTH 8
#define HEIGHT 8

typedef struct Point
{
  char x;
  char y;
} Point;

//Board.c
#include 

        
6条回答
  •  -上瘾入骨i
    2021-01-12 10:37

    Hummm... isn't your char unsigned by default? In that case the range would be 0-255, which means your >=0 comparison would be always true

提交回复
热议问题