Hello. Been trying to link to some C code with gdc on 64 bit, and I've been racking my brain over the following:

//tok.d
import std.stdio;
struct x {
    union _u_{
        ulong uq;
        struct _s_ {
            ushort dw;
            uint dd;
        };
        _s_ s;
    };
    _u_ u;
    ushort zz;
}

void main(){
    writeln(x.sizeof);
}


//tok.c
#include <stdint.h>
#include <stdio.h>

struct x {
    union {
        uint64_t uq;
        struct {
            uint16_t dw;
            uint32_t dd;
        } s;
    } u;
    uint16_t zz;
};

void main(){
    printf("%d\n", sizeof(struct x));
}


the d code prints 12, and the C code prints 16. Should I be expecting the two to be the same?

Reply via email to