News for hackers. Stuff that matters.
Re:Padding is hard by kazinator on Friday October 09, 2015 @12:50PM (#10361422)
That is what FFI is for, right? Native structures do whatever they want. When gluing to C code, you use your FFI primitives to express the interfaces; and the structures which are expressed there are made to correspond to the C layout in some way.

You generally don't want to be constraining how data structures work in a language so that they can be handed off to C code directly. (Unless perhaps you're writing a language that is nearly a C dialect or something.)

Re:Padding is hard by ori_b on Friday October 09, 2015 @02:29PM (#10362314)
You don't want to rearrange structs on every system call. That would be slow.
Re:Padding is hard by tedunangst on Friday October 09, 2015 @03:05PM (#10362563)
I think the idea is you would use the "FFI" type throughout the program, perhaps embedded in a larger structure if you need to track additional data.

The same thing is frequently done in C. Wire format data gets padded and __packed as necessary, and then that's usually the program representation as well.