Similar as the special tokens __FILE__, __LINE__,.. I would like to have a token telling me what compiler has been used and what version the compiler had.
This could than be included in the log of the application and may help tracking or finding problems.
Maybe __COMPILER__? Resulting in e.g. "DMD 1.014"
Comment #1 by daniel.keep+d.puremagic.com — 2007-05-02T07:53:56Z
See std.compiler.
Comment #2 by fvbommel — 2007-05-02T07:55:48Z
> Similar as the special tokens __FILE__, __LINE__,.. I would like to have a
> token telling me what compiler has been used and what version the compiler had.
Theoretically, you could use the constants defined in std.compiler.
In practice, they're typically out-of-date. (case in point: they're
currently at version 1.002 for DMD 1.014 :( )
Also, it seems the version distributed with GDC wasn't modified to
reflect that fact, it claims to be "Digital Mars D 1.002" (like DMD
1.002 to 1.014, apparently)...
> This could than be included in the log of the application and may help tracking
> or finding problems.
> Maybe __COMPILER__? Resulting in e.g. "DMD 1.014"
If std.compiler was properly updated, you could use something like
---
import std.compiler;
import std.stdio;
void main() {
writefln("%s %d.%03d",
std.compiler.name,
std.compiler.version_major,
std.compiler.version_minor);
}
---
to get a string representation.
Comment #3 by StefanLiebig — 2007-05-02T08:10:01Z
Oh, I am sorry! I should have found that. I guess I was expecting something different within std.compiler.
Comment #4 by StefanLiebig — 2007-05-02T08:41:54Z
That is too bad. So, why not the special token?
Within mars.c there is already:
copyright = "Copyright (c) 1999-2007 by Digital Mars";
written = "written by Walter Bright";
version = "v1.014";
That looks fine to me and it seems to be up-to-date.
Information that is not up-to-date but should be is confusingly.
Comment #5 by smjg — 2007-05-02T18:52:33Z
That std.compiler is out of date is a bug. Adding extra language features to get around this bug wouldn't make sense - if Walter can't keep std.compiler up to date, how would he be able to keep the workaround up to date?
Comment #6 by StefanLiebig — 2007-05-03T01:02:58Z
Yes, std.compiler is out-of-date.
However, the information in mars.c is correct. I have scanned all my dmd downloads (32) and they where all correct.
I don´t know how the version gets into mars.c. Manually or automatically (build process)? If manually than there is the tedious job of maintaining two locations. If automatically than the automatism has to be extended so that both locations are in sync.
I don´t care from where I get the information, but it must be correct and I need to trust that information.
Comment #7 by smjg — 2007-05-07T08:04:41Z
(In reply to comment #6)
> I don´t care from where I get the information, but it must be correct and I
> need to trust that information.
Indeed. But that we can't trust the information in std.compiler makes it as bad as non-existent, if not worse. I've just filed issue 1218, which aims at fixing this problem rather than working around it.