char等同于signed char吗

事因组里一位童鞋疑惑相同的代码在ARM和x86上运行结果不同,ARM运行结果完全不符合他的预期,分别如图所示

ARM

QQ截图20161127160334

x86

QQ截图20161127160517
奇了怪了,gcc怎么就跑出这个warming呢,在我一直用C的经验看来char就是等同signed char的,可是warming和我的观点冲突啊,完全糊涂了,难道是gcc新版本改了什么?回头一想,应该不是新版本问题,果断拿出我柜子下的C99,翻到了type的章节,看到一段

The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.

最后那句话就完美解答了我的疑惑:),意思就是说char的行为在不同的实现上等同于signed char或unsigned char其中的一个,说白了就是说char代表什么是由具体的implementation决定的,另外这段话的所在页下面也提供了判断当前实现采用哪一种策略的方法:

CHAR_MIN, defined in , will have one of the values 0 or SCHAR_MIN, and this can be used to distinguish the two options. Irrespective of the choice made, char is a separate type from the other two and is not compatible with either.

作为C programmer以后还是别用char a = -1这种写法了,应该要注明unsigned或signed的qualified或者typedef一些诸如UCHAR这类让人能容易分辨的new type identifier

references:

[1]ISO/IEC9899-1999(E)
[2]http://www.arm.linux.org.uk/docs/faqs/signedchar.php