On Tuesday, 25 February 2014 at 12:45:06 UTC, Cherry wrote:
Hello

I want to define an enum int, but I want to make it possible to set its value when I run dmd from the command line. Is it possible in D?

No, D does not allow passing values via the compiler command line. You can use the -debug=xxx or -version=xxx to enable debug(xxx) or version(xxx) blocks.

For arbitrary values, you will need intermediary files. You can use the import(filename) construct to read a file from disk during compilation, like so:

echo 42 > foo.txt

cat > test.d
import std.conv, std.string;
enum foo = to!int(import("foo.txt").strip());
^D

dmd -J. test.d

Reply via email to