类型匹配错误 - 为什么?

时间:2013-11-11 00:54:23

标签: c gcc gdb

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

1 个答案:

答案 0 :(得分:3)

error: array subscript has type ‘char'

它告诉你数组下标cmdlenfrom

如何定义cmdlenfrom?其中一个是char吗?我怀疑......