how to detect OS architecture?

Marco Leise Marco.Leise at gmx.de
Mon Dec 16 05:52:12 PST 2013


Am Mon, 16 Dec 2013 08:19:40 -0500
schrieb Hugo Florentino <hugo at acdam.cu>:

> So currently D has no specific function for detecting the OS 
> architecture at runtime? I had not expected this.

You are the first to raise this question. I guess most of us
just install either a 32-bit version or a 64-bit version and
never found a need to ask from inside the running program if
it is actually the correct architecture. Your launcher
use-case stands out.

But there is really more to it than 32 or 64. There is also
x32, which is a mix of 32-bit pointers with 64-bit CPU
features, giving the best overall performance. Also, while dmd
only emits x86 code, the language and the standard library
strive to be architecture independent except for some minimal
requirements for data types or thread local storage.

And a function like that should probably return an array of
supported ABIs, like [amd64, x32, x86] with the "main" or
most feature rich architecture in index 0. Just my 2¢

-- 
Marco



More information about the Digitalmars-d-learn mailing list