www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.system reports win32 when running OS X

reply Dave Chapman <donte5379 comcast.net> writes:
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?



import std.stdio;
import std.system;

void main (string[] args) {
   immutable OS os;
   writefln("OS = %s",os);
}
Feb 01 2017
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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?



 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
Feb 01 2017
next sibling parent reply Andrea Fontana <nospam example.com> writes:
On Wednesday, 1 February 2017 at 21:43:09 UTC, Ali Çehreli wrote:
 That's a local variable that you've defined. Since OS.init 
 happens to be OS.win32, that's what you get.
:) Maybe it should be "unknown" or "undefined" :)
Feb 02 2017
parent Bauss <jj_1337 live.dk> writes:
On Thursday, 2 February 2017 at 08:42:44 UTC, Andrea Fontana 
wrote:
 On Wednesday, 1 February 2017 at 21:43:09 UTC, Ali Çehreli 
 wrote:
 That's a local variable that you've defined. Since OS.init 
 happens to be OS.win32, that's what you get.
:) Maybe it should be "unknown" or "undefined" :)
You can always make a pull request for that and then see if everybody agrees or if there's a specific reason why it initializes to Windows.
Feb 02 2017
prev sibling parent Dave Chapman <donte5379 comcast.net> writes:
On Wednesday, 1 February 2017 at 21:43:09 UTC, Ali Çehreli wrote:
 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?



 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
Ali, Thank you. I've got it working. I had to use writefln("OS = %s",std.system.os); to get it to compile. Dave
Feb 02 2017