unsigned short* vs unsigned long* -- help!Ge Wei Da Xia,
I'm writing a c program which utilizes someone else's function. This function takes in a bit vector by "unsigned short * " pointer. However, the corresponding bit vector I pass to this function is constructed with "unsigned long * " pointer. Therefore, in Linux and Windows, because of the endian convention, the bit vector passed over is not what I want. For example, under unsigned long pointer, I have 0x12345678. But when casted into unsigned short, it becomes 0x5678 0x1234.
Now, the only thing I can think of is to either change my own program (which needs quite a lot of changes) or change that person's program (which needs just as much changes, and the code is hard to understand).
So I'm wondering, does any of the wizards here have better ways of dealing with this?
Thanks very very much![Clex (8-22 13:40, Long long ago)]
[ 传统版 |
sForum ][登录后回复]1楼
copy ur input data to a bufferthen cast it into short format.
thus without changing your portion and
the 3rd function, u will handle this problem.
[小诸葛 (8-22 14:03, Long long ago)]
[ 传统版 |
sForum ][登录后回复]2楼