I have a C# background. I am very much a newbie to a low-level language like C.
In C#, struct
's memory is laid out by the compiler by default. The compiler can re-order data fields or pad additional bits between fields implicitly. So, I had to specify some special attribute to override this behavior for exact layout.
AFAIK, C does not reorder or align memory layout of a struct
by default. However, I heard there's a little exception that is very hard to find.
What is C's memory layout behavior? What should be re-ordered/aligned and not?
#pragma pack
but with more fine-grained control over the semantics. – Heavyarmed