4 ms·
Using a byte array and manually marshalling stuff in and out is tedious, but it does avoid alignment issues. There's a certain amount of irony that dynamic lan
by Roboprog 10y ago
Using a byte array and manually marshalling stuff in and out is tedious, but it does avoid alignment issues.
There's a certain amount of irony that dynamic languages (e.g. Perl) make it easier to implement something like "pack" and "unpack" to move values in and out of such a byte array, due to the variable type arguments/results of the "unpacked" values.
- Roboprog 10y agoOtherwise, I assume that avoiding this problem is a matter of putting the larger elements at the start of the struct, and the smaller elements at the end (with the exception that for a nested array, you consider the element size, not the total array) 8 byte entries, then 4 byte entries, 2 byte entries, chars/bytes, bits.