gnu linux上のARMのデフォルトcharは記号付きではありません.マイクロソフトwinceのcharはデフォルトでsignedです.


C
標準表示charタイプは、特定のコンパイラ、プロセッサ、またはそれらの両方によって、シンボルを持たなくてもよい
共同
と決める
底charは符号付き
合うか持たないか
番号が合う.
ほとんどのアーキテクチャでは、charのデフォルトは記号付きであり、-128から127の間で値を取ることができます.いくつかの例があります
外、
例えばARM
アーキテクチャ上、
charは文字を持たない
は、0~255の範囲で値をとります.
たとえば、デフォルトcharには記号が付いていません.次のコードは、実際には-1ではなく255をiに与えます.
char i = -1;
別のマシンでは、デフォルトcharに記号が付いていて、正確に-1をiに与えます.プログラマーが本気で-1保
iに存在する場合、前のコードは次のように変更されます.
    signed char i = -1;
また、プログラマが255を格納したい場合、コードは次のようになります.
     unsigned char = 255;   
自分のコードでcharタイプを使用している場合は、記号付きと記号なしで保証する必要があります.
コードは問題ありません.どちらを使うかを明確にできれば、直接宣言します.
The following email fragment appeared on the linux-arm mailing list recently: consider this simple program:
 
 
int main(void)
{
    char i = -1;
    printf("%d
", i); return 0; }
The print out is 255 in stead of -1, unless I define i as signed char i;then I get the "-1" print out. The above code is actually buggy in that it assumes that the type "char" is equivalent to "signed char". The C standards do say that "char" may either be a "signed char" or "unsigned char" and it is up to the compilers implementation or the platform which is followed. As the poster points out, the above code does not work as expected if "char" is "unsigned". It is difficult to detect this code at compile time, since GCC does not issue any warnings. The only way to detect it is either by visual examination of the code, or by actually running it and finding a problem.This causes problems on ARM based machines since "char" is of the "unsigned" variety, which allows the compiler to generate faster, more efficient code. ARM is not alone in this - SGI Mips running IRIX also encounters this problem.However, dispite the lack of warning for the above case, GCC does warn with the following code:
{
    char foo;
    foo = bar();
    if (foo == -1) {
        ...
    }
}

Code like the above will generate a compiler warning, which will be one of the following depending on the actual test used:  warning: comparison is always 0 due to limited range of data type warning: comparison is always 1 due to limited range of data type Please note however that the above warnings are not issued if "char"is "signed"and therefore can be difficult to pick up when compiling in such an environment. The following table lists the four types of code which cause problems when "c"is declared as just "char", and the most likely correct method of fixing the code.