sbarisic / NuklearDotNet

.NET binding for the Nuklear immediate mode GUI
Other
189 stars 15 forks source link

Put bigger fields later in unions #2

Closed leafi closed 6 years ago

leafi commented 6 years ago

Per http://yizhang82.me/pinvoke-union, (at least some) .NET Framework versions work on structs with Explicit layouts with everything at FieldOffset(0) (i.e. unions) by copying each field one at a time.

That means that if you have a smaller field after a big one, things can get trashed.

For safety, put the biggest fields at the end of each union.