Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これがテストコードです。
char ch = 0xff; int i = ch; printf("%d\n", i);
i386 gcc-4.4.5 では、出力は -1です。しかし、powerpc-e300c3-linux-gnu-gcc-4.1.2(MPC8315 クロスコンパイラ) では、出力は 255です。
なにが問題ですか?なぜ gcc-4.1.2 の出力は 255 なのですか?
ご回答有難うございます...
char署名されているか署名 されていないかは実装定義です。
char
どうやら x86 コンパイラでは署名されており、PowerPC コンパイラでは署名されていないようです。
移植性のために、unsigned charまたはsigned char署名を気にする場所ならどこでも使用してください。
unsigned char
signed char