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?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…