Support for bit fields? 路 Issue #700 路 msgpack/msgpack

您所在的位置:网站首页 信息技术与化学融合的教学设计 Support for bit fields? 路 Issue #700 路 msgpack/msgpack

Support for bit fields? 路 Issue #700 路 msgpack/msgpack

#Support for bit fields? 路 Issue #700 路 msgpack/msgpack| 来源: 网络整理| 查看: 265

Thanks for the response. So this looks like it will pack each member into a uint32_t of its own, which effectively makes the packed data 5 ints of msgpack data.

I was also thinking about how to pack a 5 member bit field like Bits into just 1 int of msgpack format data, since the bitfield is meant to only occupy 1 int of space. Our solution for this was to use a union pattern, where one member of the union is this Bits struct, and one is an int acting as "raw" data. Then we use the bitfield for our internal code, but use msgpack to pack the "raw" data when sending a message.

#include union dataForm{ struct Bits { uint32_t opCode : 5; uint32_t header : 3; uint32_t source : 5; uint32_t destination : 5; uint32_t offset : 13; }; uint32_t raw; };


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3