Setting versions for imports
div0
div0 at users.sourceforge.net
Tue Oct 2 11:18:06 PDT 2007
Jascha Wetzel wrote:
> Suppose we have two modules test1 and test2:
>
> module test1;
> version(asdf) {}
> else { static assert(0); }
>
> module test2;
> version = asdf;
> import test1;
>
> This won't compile. Is there a way to get the intended behavior without
> passing the versions on the command line?
no. version declarations only apply to the module in which they are
declared.
http://www.digitalmars.com/d/version.html
so you can't use a module as a config.h in that way
besides what's wrong with passing them on the commandline?
If you really want to go that way, you could use static if's to achieve
something similar I guess.
config.d
========
const char[] myVersion = "someVer";
some.d
======
static if( myVersion == "someVer" )
{ // someVer
}
else // bail
static assert(0);
More information about the Digitalmars-d-learn
mailing list