Best way to confine project to 64 bit builds only?

Dennis dkorpel at
Sat Oct 17 15:03:29 UTC 2020

On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote:
> I have inherited an open source C project that assumes that the 
> size of a long and the size of a pointer are the same, and I 
> have translated it into very similar D just like 
> D has the size of long fixed at 64 bits, so a pointer now has 
> to be 64 bits.

If you want to exactly match the original C code's semantics, I 
suggest translating (unsigned) long with c_long or c_ulong. You 
can import them here:
import core.stdc.config: c_long, c_ulong;

Then you could add this:
static assert(c_long.sizeof == size_t.sizeof);

This will fail on Windows 64 bit, where C longs are 32-bit and 
pointers 64-bit.

More information about the Digitalmars-d-learn mailing list