1

我从 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 提供可用的格式,警告就会变成错误。

4

1 回答 1

3
error: array subscript has type ‘char'

它告诉你数组下标cmdlenfrom

cmdlen又是如何from定义的?其中一个是char吗?我怀疑是这样...

于 2013-11-11T00:58:27.593 回答