externally imposed conditional compilation
Gor Gyolchanyan
gor.f.gyolchanyan at gmail.com
Fri Nov 23 14:20:29 PST 2012
Thanks! I completely forgot about import expressions! I can just as well
supply a config.d with all necessary definitions!
I thing another way is to have the entire module a template and instantiate
that template with necessary parameters. Although that means one has to
have an additional namespace.
On Sat, Nov 24, 2012 at 2:01 AM, Peter Alexander <
peter.alexander.au at gmail.com> wrote:
> On Friday, 23 November 2012 at 11:38:31 UTC, Gor Gyolchanyan wrote:
>
>> What's the best/standard way translating this to D?
>>
>
> One way is to use import expressions:
>
> 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.
>
--
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121124/779374f0/attachment.html>
More information about the Digitalmars-d
mailing list