Open laohuang112 opened 7 years ago
Under arm linux, The symbol is decleared unsigned long in dlib/compress_stream/compress_stream_kernel_1.h,
unsigned long symbol;
unsigned long count = 0;
So, when I have the following code:
symbol = 232;
printf("%d\n",static_cast<char>(symbol));
printf("%d\n",static_cast<int>(symbol));
Obviously, I should get the result: -24 232 Accoding to the source code of sputc,
int_type
sputc(char_type __c)
{
int_type __ret;
if (__builtin_expect(this->pptr() < this->epptr(), true))
{
*this->pptr() = __c;
this->pbump(1);
__ret = traits_type::to_int_type(__c);
}
else
__ret = this->overflow(traits_type::to_int_type(__c));
return __ret;
}
So, out.sputc(static_cast
But, why this didn't happen under x64?
In my demo project, invoke get_frontal_face_detector(); , when run, i will get the following error:
I've checked the source code, in dlib/compress_stream/compress_stream_kernel_1.h,
I don't know the purpose of this code : out.sputc(static_cast(symbol)), sputc should change char to int, but when symbol equal or greater than 128, sputc will get a negtive signed char value. Then the demo running failed. The cross compiler is: arm-linux-gnueabi-gcc-4.7.1
But everything works fine in Ubuntu 14.04 x64, GCC 4.8.
How to fix it?