3 ms·
Unpacked structs are also very useful for parsing network data. You take a package, cast it to an unpacked struct, and can access everything nicely. Many a spa
by 4gotunameagain 1y ago
Unpacked structs are also very useful for parsing network data. You take a package, cast it to an unpacked struct, and can access everything nicely.
Many a spacecraft telemetry stacks work like that.
- JonChesterfield 1y agoThe alias analysis pass in your C or C++ compiler will savage you for doing that unless you're careful with annotations or compiler flags though.
- 4gotunameagain 1y agoYeap, can definitely be a foot gun ! Even worse, sometimes you won't even get warnings about it, and then scratch your head why the binary seemingly has a mind of its own.. don't ask me how I know !
- rkangel 1y agoI think you mean "packed" structs. Otherwise you've got padding in your communication protocol. If you do this you also need to be careful of byte order.
- 4gotunameagain 1y agoYeah you're right, I mixed it up with unpadded ! And you're right about the second point as well, typically there will be network order to cpu order macros to ensure portability