C # provides StructLayoutAttribute.Pack, but its behavior "every member gets at least the specified alignment, whether he wants it or not," whereas the behavior of the #pragma package in C ++ "every member gets the alignment he wants, if only he wants more than the specified alignment, and in this case he does not guarantee more than that. "
Is there a way to force the layout of a structure in C # to be the same as the layout of a similar structure in C ++ with a specific package #pragma, besides using StructLayout (LayoutKind.Explicit) and FieldOffset for each member, or inserting unused fill elements?
source
share