最近在做把vs项目移植到android上,但是有个问题,不知到底是什么错误,原本有使用到一个压缩的函数,但是我发现调用该函数重新生成的文件内容是不同的,都是些位操作,看不咋懂:// 首先是类型定义
#define UBYTE unsigned char
#define UWORD unsigned int  
#define ULONG unsigned long 
#define FLAG_BYTES    4     
#define FLAG_COMPRESS 0     
#define FLAG_COPY     1    #define PS *p++!=*s++  
#define ITEMMAX 16   
/// Fast copy routine
void fast_copy(UBYTE *p_src,UBYTE *p_dst,ULONG len) 
{
    while (len--)
*p_dst++ = *p_src++;
}  /// 压缩函数void Compress(UBYTE *p_src_first,ULONG src_len,UBYTE *p_dst_first,ULONG *p_dst_len)
{
UBYTE *p_src = p_src_first, *p_dst = p_dst_first;
UBYTE *p_src_post = p_src_first + src_len, *p_dst_post = p_dst_first + src_len;
UBYTE *p_src_max1 = p_src_post - ITEMMAX, *p_src_max16 = p_src_post - 16*ITEMMAX;
UBYTE *hash[4096], *p_control;
UWORD control = 0,control_bits = 0; *p_dst = FLAG_COMPRESS; 
p_dst += FLAG_BYTES;
p_control = p_dst;
p_dst += 2; while (TRUE)
{
UBYTE *p,*s; 
UWORD unroll = 16,len,index; 
ULONG offset; if (p_dst > p_dst_post) goto overrun; if (p_src > p_src_max16)
{
unroll=1;
if (p_src > p_src_max1)
{
if (p_src == p_src_post) break;
goto literal;
}
}begin_unrolled_loop:
index = (( 40543 * ((((p_src[0]<<4)^p_src[1])<<4)^p_src[2]) )>>4) & 0xFFF;
p=hash[index]; 
hash[index] = s = p_src; 
offset = s - p; if (offset > 4095 || p < p_src_first || offset == 0 || PS || PS || PS)
{
literal: 
*p_dst++ = *p_src++; 
control >>= 1; 
control_bits++;
}
else
{
PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || s++;  len = s - p_src - 1;
*p_dst++ = ((offset&0xF00)>>4) + (len-1); 
*p_dst++ = offset&0xFF;
p_src += len; 
control = (control>>1) | 0x8000; 
control_bits++;
}end_unrolled_loop: 
if (--unroll)  goto begin_unrolled_loop; if (control_bits == 16)
{
*p_control = control&0xFF;
*(p_control+1) = control>>8;
p_control = p_dst; 
p_dst += 2; 
control = control_bits = 0;
}
}
control >>= 16 - control_bits;
*p_control++ = control&0xFF; 
*p_control++ = control>>8; if (p_control == p_dst) p_dst -= 2; *p_dst_len = p_dst - p_dst_first; return;overrun: 
fast_copy(p_src_first,p_dst_first+FLAG_BYTES,src_len);
*p_dst_first = FLAG_COPY; 
*p_dst_len = src_len + FLAG_BYTES;
}
原本以为是Linux下类型字节不一样,但是实际输出发现和我在vs上输出的结果一样
LOGI("WriteOpen(): unsigned=%d", sizeof(unsigned));            //输出:4
LOGI("WriteOpen(): unsigned char=%d", sizeof(unsigned char));  //输出:1
LOGI("WriteOpen(): unsigned int=%d", sizeof(unsigned int));    //输出:4
LOGI("WriteOpen(): unsigned long=%d", sizeof(unsigned long));  //输出:4不知哪位大哥有空可以帮忙看一下