Thanks! I completely forgot about import expressions! I can just as well supply a config.d with all necessary definitions!
On Friday, 23 November 2012 at 11:38:31 UTC, Gor Gyolchanyan wrote:One way is to use import expressions:
What's the best/standard way translating this to D?
import std.stdio;
import std.conv;
enum value = import("value").to!int();
void main()
{
static if (value < 100)
writeln("<100");
else
writeln(">100");
}
Compile using:
dmd -Jpath/to/value source.d
"value" should be a file containing a single integer with no new line. It will be read in at compile time and converted to a manifest integer constant, which you can use in static if statements.