在C#中,你可以使用类似这样的对齐属性:
[StructLayout(LayoutKind.Explicit)]
public struct Message
{
[FieldOffset(0)]
public int a;
[FieldOffset(4)]
public short b;
[FieldOffset(6)]
public int c;
[FieldOffset(22)] //Leave some empty space just for the heck of it.
public DateTime dt;
}
在标准C++中是否有类似的东西,可以让您对内存中的结构布局进行精细控制?