4 ms·
Why are unions within structs not portable?
by atiedebee 2y ago
Why are unions within structs not portable?
- cantrecallmypwd 2y agoUndefined padding and alignment.
- Keyframe 2y agoyou can do explicit padding and you can force alignment; latter might be compiler specific until C11 at least. You can always check for the struct layout as an assert.. it's doable.
- atiedebee 2y agoThat doesn't really matter for sum types as used in this blog, does it? As long as you're not serialising the struct or accessing it through pointers of different types it ought to work anywhere.