www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why is Linux the only OS in version identifier list that has a

reply Zekereth <viserion.thrall gmail.com> writes:
So I was just testing some code and couldn't figure out why it 
wasn't working. My version block looked like this:

version(Linux)
{
...
}

Looking at the list(unless I'm missing something) Linux is the 
only OS that is lowercase. I'm guessing most people use Posix 
instead and never encounter this problem.

Regard,
Zekereth
Apr 10 2016
next sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote:
 So I was just testing some code and couldn't figure out why it 
 wasn't working. My version block looked like this:

 version(Linux)
 {
 ...
 }

 Looking at the list(unless I'm missing something) Linux is the 
 only OS that is lowercase. I'm guessing most people use Posix 
 instead and never encounter this problem.
It's an artifact of history. When this was first introduced, Walter's intent was to match the casing used in gcc preprocessor definitions. Since that time, we've standardized on capitalization for everything, but 'linux' lives on. I would like to see 'Linux' introduced for consistency and to avoid errors like yours (a bug lived in Phobos for a long time because of this) while maintaining 'linux' for backwards compatibility.
Apr 10 2016
parent Zekereth <viserion.thrall gmail.com> writes:
On Monday, 11 April 2016 at 00:51:19 UTC, Mike Parker wrote:
 It's an artifact of history. When this was first introduced, 
 Walter's intent was to match the casing used in gcc 
 preprocessor definitions. Since that time, we've standardized 
 on capitalization for everything, but 'linux' lives on. I would 
 like to see 'Linux' introduced for consistency and to avoid 
 errors like yours (a bug lived in Phobos for a long time 
 because of this) while maintaining 'linux' for backwards 
 compatibility.
Thanks, that makes sense. It would be nice if Linux could be introduced. I'll just have to remember from now on. Thanks again!
Apr 10 2016
prev sibling next sibling parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 04/10/2016 03:03 PM, Zekereth wrote:
 So I was just testing some code and couldn't figure out why it wasn't
 working. My version block looked like this:

 version(Linux)
 {
 ...
 }

 Looking at the list(unless I'm missing something) Linux is the only OS
 that is lowercase. I'm guessing most people use Posix instead and never
 encounter this problem.

 Regard,
 Zekereth
As a workaround, you can set version to Linux yourself: version (linux) { version = Linux; } void main() { version (Linux) { import std.stdio; writeln("Linux worked!"); } }
Apr 10 2016
parent reply Zekereth <viserion.thrall gmail.com> writes:
On Monday, 11 April 2016 at 01:15:27 UTC, Ali Çehreli wrote:
 As a workaround, you can set version to Linux yourself:

 version (linux) {
     version = Linux;
 }

 void main() {
     version (Linux) {
         import std.stdio;
         writeln("Linux worked!");
     }
 }
That's interesting that will help. Thanks for that!
Apr 10 2016
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 4/10/16 9:19 PM, Zekereth wrote:
 On Monday, 11 April 2016 at 01:15:27 UTC, Ali Çehreli wrote:
 As a workaround, you can set version to Linux yourself:

 version (linux) {
     version = Linux;
 }

 void main() {
     version (Linux) {
         import std.stdio;
         writeln("Linux worked!");
     }
 }
That's interesting that will help. Thanks for that!
I highly recommend not to do this. New version assignments do not live outside the module, so you have to do this in EVERY module you want to use it. Better to pass on the command line. Even better to just use the standard version identifier :) -Steve
Apr 12 2016
prev sibling parent reply marcpmichel <marc.p.michel gmail.com> writes:
On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote:
 Looking at the list(unless I'm missing something) Linux is the 
 only OS that is lowercase.
Is it because Linux is not an OS ? :p
Apr 11 2016
parent reply Brian Schott <briancschott gmail.com> writes:
On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:
 Is it because Linux is not an OS ? :p
I gnu somebody would bring that up.
Apr 11 2016
next sibling parent Zekereth <viserion.thrall gmail.com> writes:
On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:
 On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:
 Is it because Linux is not an OS ? :p
I gnu somebody would bring that up.
/sigh so did I.
Apr 11 2016
prev sibling parent reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:
 On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:
 Is it because Linux is not an OS ? :p
I gnu somebody would bring that up.
There's actually a serious point here, though -- as D is ported to other platforms and architectures, it's going to wind up being used to target environments that use a Linux kernel but are not GNU. Conversely, there may also be systems that are GNU but not Linux (e.g. the recent proposal for an Ubuntu flavour based on the FreeBSD kernel). Are druntime and phobos ready to deal with those kinds of eventuality?
Apr 12 2016
parent reply Jonathan M Davis via Digitalmars-d-learn writes:
On Tuesday, April 12, 2016 17:22:05 Joseph Rushton Wakeling via Digitalmars-d-
learn wrote:
 On Tuesday, 12 April 2016 at 01:32:02 UTC, Brian Schott wrote:
 On Monday, 11 April 2016 at 23:01:08 UTC, marcpmichel wrote:
 Is it because Linux is not an OS ? :p
I gnu somebody would bring that up.
There's actually a serious point here, though -- as D is ported to other platforms and architectures, it's going to wind up being used to target environments that use a Linux kernel but are not GNU. Conversely, there may also be systems that are GNU but not Linux (e.g. the recent proposal for an Ubuntu flavour based on the FreeBSD kernel). Are druntime and phobos ready to deal with those kinds of eventuality?
Well, work has been done to make it so that different runtimes will work - e.g. there's a CRuntime_Glibc and a CRuntime_Bionic. So, druntime is a lot better off than just linux vs FreeBSD vs whatever. But it wouldn't surprise me in the least if someone using something like Debian GNU/kFreeBSD would find some problems with what we currently have. - Jonathan M Davis
Apr 12 2016
parent reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On Tuesday, 12 April 2016 at 18:23:25 UTC, Jonathan M Davis wrote:
 Well, work has been done to make it so that different runtimes 
 will work - e.g. there's a CRuntime_Glibc and a CRuntime_Bionic.
That's pretty cool. Was that a result of the recent Android porting work, or was it a longer-standing division?
                  So, druntime is a lot better off than just 
 linux vs FreeBSD vs whatever. But it wouldn't surprise me in 
 the least if someone using something like Debian GNU/kFreeBSD 
 would find some problems with what we currently have.
Ah, fun stuff :-) BTW, glad to see you will be making it to DConf -- looking forward to catching up with you!
Apr 12 2016
parent Jonathan M Davis via Digitalmars-d-learn writes:
On Tuesday, April 12, 2016 19:15:33 Joseph Rushton Wakeling via Digitalmars-d-
learn wrote:
 On Tuesday, 12 April 2016 at 18:23:25 UTC, Jonathan M Davis wrote:
 Well, work has been done to make it so that different runtimes
 will work - e.g. there's a CRuntime_Glibc and a CRuntime_Bionic.
That's pretty cool. Was that a result of the recent Android porting work, or was it a longer-standing division?
I believe that some of the LDC guys in particular (and maybe GDC guys too) have been adding stuff like that over time to support the various platforms that they support, though Bionic is specifically Android if I understand correctly, and I think that it was spurred adding the Glibc version specifically. IIRC, the other major divide like that is Digital Mars vs Microsoft for the Windows C runtime, and I think that the addition of 64-bit support to Windows is what ultimately spurred that one on.
                  So, druntime is a lot better off than just

 linux vs FreeBSD vs whatever. But it wouldn't surprise me in
 the least if someone using something like Debian GNU/kFreeBSD
 would find some problems with what we currently have.
Ah, fun stuff :-) BTW, glad to see you will be making it to DConf -- looking forward to catching up with you!
:) - Jonathan M Davis
Apr 12 2016