wrong struct alignment
dd0s via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 1 13:01:06 PDT 2015
i have the following struct, and i expect it to have 30 bytes
but sizeof tells me it has 32 bytes. dmd seems to still use 4byte
alignment altough i specified to align 2bytes.
struct netadr_t {
align(2):
int type; // 0
int scope_id; // 4
short port; // 8 // <-- this is 4 bytes instead of 2
int sock; // 10
union {
ubyte[4] ip; // 14
ubyte[10] ipx;
ubyte[16] ip6;
}
}
since i'm interfacing with a c library the struct layout has to
be equal :(
More information about the Digitalmars-d-learn
mailing list