我从 gcc 收到以下警告:
labs.c:760:2: error: array subscript has type ‘char’ [-Werror=char-subscripts]
wrbuf[cmdlen++]=(unsigned char)(basictoken[from]>>8);
^
cc1: all warnings being treated as errors
使用 gdb 调试它会报告相似类型的双方:
760 wrbuf[cmdlen++]=(unsigned char)(token[from]>>8);
(gdb) whatis wrbuf[cmdlen]
type = unsigned char
(gdb) whatis (unsigned char)(token[from]>>8)
type = unsigned char
为什么会有这个警告?这让我很不安,因为如果我想为 ctypes 提供可用的格式,警告就会变成错误。