www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2021] New: version(linux) is inconsistent

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021

           Summary: version(linux) is inconsistent
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


If the version for Windows is going to be capitalized, then the version for
Linux needs to be capitalized too.

I recommend deprecating version(linux) and adding the default version(Linux). 
By deprecate I mean just remove it from the documentation and allow it to
gradually be forgotten. 

Maybe someone was under the impression that "Windows" is a proper name, but
"linux" is not, however, Googling for "linux" turns up many many uses of the
name capitalized.  In particular sites that should know seem to capitalize it,
like linux.org: http://www.linux.org/info/index.html


-- 
Apr 20 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #1 from larsivar igesund.net  2008-04-21 16:40 -------
Also, uname gives Linux, which tends to be the source used for scripted and
programmed checks for the OS. uname on FreeBSD returns freebsd for instance,
which turns out to also be the version identifier for that OS in GDC.

This would allow for things like

./gdc -fversion=`uname`


-- 
Apr 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #2 from afb algonet.se  2008-04-21 17:49 -------
(In reply to comment #1)
 Also, uname gives Linux, which tends to be the source used for scripted and
 programmed checks for the OS. uname on FreeBSD returns freebsd for instance,
 which turns out to also be the version identifier for that OS in GDC.

No, the uname on FreeBSD returns "FreeBSD" and the uname on Mac OS X returns "Darwin". The version identifiers are lower-cased for all of the systems, with the common pre-defined definition in GDC being version(Unix) which matches version(Windows). Unfortunately, DMD is missing "Unix" and only has "linux". See http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Version
 This would allow for things like
 
 ./gdc -fversion=`uname`

Why would you need this ? It's built-in anyway... But it's used for Makefile inclusions in wxD, for instance. So it comes in handy once in a while. The definitions for MinGW and Cygwin are rather ugly, though. (includes version and is upper-case, looks something like "MINGW32_NT-5.1" or "CYGWIN_NT-5.1") Anyway, the whole issue was brought up years ago (2005) and should be a WONTFIX. See for instance http://www.digitalmars.com/d/archives/digitalmars/D/37778.html#N37933 and http://www.digitalmars.com/d/archives/D/gnu/1208.html. --
Apr 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #3 from wbaxter gmail.com  2008-04-21 18:41 -------
(In reply to comment #2)

 Anyway, the whole issue was brought up years ago (2005) and should be a
 WONTFIX. See for instance
 http://www.digitalmars.com/d/archives/digitalmars/D/37778.html#N37933 and
 http://www.digitalmars.com/d/archives/D/gnu/1208.html.

Those threads are mostly about getting DMD to predefine Posix or Unix. That's not what this bug is about. This is about the capitalization of "Linux" being inconsistent, and that's it. The second thread does include this rationale for "version(linux)" from Walter: """ The reason DMD uses "linux" is because gcc under Linux predefines "linux". """ http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=D.gnu&artnum=1240 I have no idea why DMD should define its Linux version identifier based on GCC's behavior, rather than doing something consistent and which makes sense for D. But even if for some bizarre reason people feel that D's versions should follow the conventions of #defines established by some particular implementations of C, there's still an inconsistency, because the preprocessor symbol predefined on Windows systems is not "Windows" or "Win32", but rather "WINDOWS" or "WIN32" or "_WIN32". --
Apr 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #4 from afb algonet.se  2008-04-22 01:30 -------
My point was just that "version(Windows)" and "version(Unix)" already have a
consistent capitalization in the portable compiler.

And "version(linux)" and "version(darwin)" and "version(cygwin)" and
"version(freebsd)" and "version(solaris)" do too.


-- 
Apr 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #5 from wbaxter gmail.com  2008-04-22 01:41 -------
I see.  I agree that's a reasonable and well thought out way to make everything
consistent.


-- 
Apr 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Comment #6 from bugzilla digitalmars.com  2008-04-22 20:29 -------
As has been pointed out in the comments, "linux" is used because that is the
way gcc on Linux defines it. There isn't any consistent way to do it, so might
as well just use what the Linux programmers are used to using.


-- 
Apr 22 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2021





------- Comment #7 from wbaxter gmail.com  2008-04-22 20:48 -------
Still seems kind of silly to me.

First because this is D -- why should a D user be expected to have any
knowledge of how GCC usually behaves on Linux.

And second because I think you'd be the first to agree that the way
preprocessor symbols are defined in C/C++ is totally fubar and inconsistent. 
Why perpetuate a broken system?

That said, the way GDC does it, as AFB pointed out, takes the lemon that is DMD
version names, and makes lemonade, by repositioning "linux" as a subcategory of
"Unix".  It would definitely be nice if DMD would pick up this idea and add a
"Unix" version.


-- 
Apr 22 2008