How do I instantiate this struct? I only need to set and use the sched_priority parameter. In C I'd just allocate enough memory for it and set the first sizeof(int) bytes to the desired value. How to do the same in rust?
Try MaybeUninit::<sched_param>::zeroed().assume_init(). If you'd really like to avoid the extra 4 byte write, you could use MaybeUninit::uninit(), but don't call assume_init() on it until you use raw pointers to write that first int.
Thanks for the reply. I have also just noticed it is not marked as repr(C), does that actually mean that sched_priority will start at the zero offset of the object's address? Oh wait, I will already have the object to work with, so there is nothing to worry about.