std.system reports win32 when running OS X

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 1 13:43:09 PST 2017


On 02/01/2017 01:34 PM, Dave Chapman wrote:
> I am running an iMac with OS X 10.11.5 (El Capitan) and dmd version 2.072.2
> The following program prints out OS = win32.
>
> Is this the intended behavior?
>
> #!/usr/local/bin/rdmd
>
> import std.stdio;
> import std.system;
>
> void main (string[] args) {
>   immutable OS os;

That's a local variable that you've defined. Since OS.init happens to be 
OS.win32, that's what you get.

>   writefln("OS = %s",os);
> }
>

What you need is the already defined std.system.os:

import std.stdio;
import std.system;

void main (string[] args) {
   writefln("OS = %s",os);
}

Ali



More information about the Digitalmars-d-learn mailing list