D alternative for C/C++ -Dfoo=42
Tobias Pankrath
tobias at pankrath.net
Tue Feb 25 05:13:09 PST 2014
> module myproggy;
> import std.stdio;
> enum foo = 5;
> enum bar = "walter";
>
> int main() {
> writeln(bar);
> return foo;
> }
>
> ... and you call compiler like:
> dmd myproggy.d -Dfoo=42 -Dbar=hello
>
> smart, new D compiler would replace enums (iff they exist in
> the source code) with the given arguments, so when you run
> myproggy, you get "walter" as output, and the exit code is 42.
I don't like it. I would prefer a CTFE-able counter part to
boost::program_options that generates thouse enums from a config
file.
More information about the Digitalmars-d-learn
mailing list