-2

If I know I am on a little-endian machine, how can I convert the endiannes of a 14-bit bitfield?

struct {
    unsigned foo : 14, bar 2;
} baz;

I have a hunch that baz.foo = htons(baz.foo) will not work properly.

4

1 回答 1

1

将它与 a 放在一个联合中,uint16_t然后交换它。

于 2013-04-06T20:26:38.187 回答