Compile time executable calling?
Peter Alexander
peter.alexander.au at gmail.com
Sat Jul 13 04:25:04 PDT 2013
On Saturday, 13 July 2013 at 11:19:49 UTC, Daniel Kozak wrote:
> A few minutes ago, I have a same issue. I need add some enum
> values as a compile option.
>
> Now I have something like this:
> version (Parser) {
> enum Application = "parser";
> }
> version (Report) {
> enum Application = "report";
> }
>
> But would be nice to have posibility to add same value as a
> compile parametr, so I could have code like this:
>
> enum Application = __traits(getParametrValue,
> "MY_APPLICATION_NAME");
>
> and compile code with some args for eg.:
> -VMY_APPLICATION_NAME=parser
You can solve this using import expressions.
---parser/config.include---
enum Application = "parser";
---report/config.include---
enum Application = "report";
---main.d---
mixin(import("config.include"));
---Makefile---
parser:
dmd main.d -Jparser
report:
dmd main.d -Jreport
More information about the Digitalmars-d
mailing list