[Issue 1210] New: Special Token for Compiler and Version
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Wed May 2 05:54:58 PDT 2007
> 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.
More information about the Digitalmars-d-bugs
mailing list