3 ms·
For that specific case, it seems like the array should be a packed struct (whatever needs it to be an array can receive an array via @bitcast). These features o
by anonymoushn 3y ago
For that specific case, it seems like the array should be a packed struct (whatever needs it to be an array can receive an array via @bitcast). These features of C designated initialization seem great though.
- flohofwoe 3y agoThere's also another solution to use slices instead of 'embedded arrays', but with slices you suddenly need to think about ownership (e.g. what happens with the referenced slices when the top-level struct is copied).
- anonymoushn 3y agoI agree that it's worth avoiding slice members for this reason if the slices are the only thing that would stop memcpy'd copies of the struct from "just working."