我有一个CFBitVector
看起来像'100000000000000'
我将字节数组传递给 的CFBitVectorGetBits
,然后包含来自 this 的值CFBitVector
。在这个电话之后,bytes[2]
看起来像:
bytes[0] == '0x80'
bytes[1] == '0x00'
这正是我所期望的。但是,当将 的内容复制bytes[2]
到unsigned int bytesValue,
值128
时,它应该是32768
. 十进制值128
由十六进制值表示0x0080
。从本质上讲,执行时字节顺序似乎是颠倒的memcpy
。这里发生了什么?这只是字节顺序的问题吗?
谢谢
CFMutableBitVectorRef bitVector = CFBitVectorCreateMutable(kCFAllocatorDefault, 16);
CFBitVectorSetCount(bitVector, 16);
CFBitVectorSetBitAtIndex(bitVector, 0, 1);
CFRange range = CFRangeMake(0, 16);
Byte bytes[2] = {0,0};
unsigned int bytesValue = 0;
CFBitVectorGetBits(bitVector, range, bytes);
memcpy(&bytesValue, bytes, sizeof(bytes));
return bytesValue;