Wednesday, April 09, 2014

When char bites ...

Got bitten by the char arithmetics in C today, while porting some native code to Android NDK.
Good reminder that the chars are not defined as signed or unsigned in the C standard and treated as unsigned by the ARM compiler for example.
To fix this problem it's better to use either something like int8_t from stdint.h or the compiler flag:
 -funsigned-char

Good luck!