Define enum value at compile time via compiler argument?

Mengu mengukagan at gmail.com
Mon Dec 25 16:22:11 UTC 2017


On Monday, 25 December 2017 at 16:13:48 UTC, Thomas Mader wrote:
> Hello,
>
> I would like to set the path to a directory at compile time but 
> it doesn't seem to be possible yet.
>
> I tried it with a -version=CustomPath argument and inside the 
> version statement in the code I tried to read the value from 
> the environment. Sadly this doesn't work because getenv can not 
> be interpreted at compile time because it has no available 
> source.
>
> Now my question is if this is somehow possible and I just don't 
> see it or would it be possible to add that somehow?
>
> Thanks in advance.
>
> Thomas

is it a relative path? if so:

     pragma(msg, __FILE_FULL_PATH__.split("/")[0..$-1].join("/"));


https://run.dlang.io/is/gRUAD6


More information about the Digitalmars-d-learn mailing list