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

后端 未结 6 1309
一向
一向 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条回答
  •  隐瞒了意图╮
    2021-01-12 10:44

    The C and C++ standards allows the character type char to be signed or unsigned, depending on the platform and compiler. Most systems, including x86 GNU/Linux and Microsoft Windows, use signed char, but those based on PowerPC and ARM processors typically use unsigned char.(29) This can lead to unexpected results when porting programs between platforms which have different defaults for the type of char.

提交回复
热议问题