version()
Mike Parker
aldacron at gmail.com
Sun Jan 15 23:28:22 PST 2012
On 1/16/2012 8:44 AM, Manu wrote:
> Why can't I do this:
>
> version( linux || OSX )
> {
> something common to each
> }
>
> ???
>
>
> This is not acceptable:
>
> version( MinGW )
> {
> version = linuxOrMinGW;
> }
> else version( linux )
> {
> version = linuxOrMinGW;
> }
>
> version( linuxOrMinGW )
> {
> seriously...?
> }
>
>
> Surely basic logical expressions within a version seem not only logical,
> but also very necessary?
> There must be a reason this is impossible, or else I can't believe it's
> not already like that...
This is something I've wanted ever since I first started using D. Really
annoying when you need to do the same sort of version checks across
multiple modules. One workaround:
----------------
module myconfig;
version(MingW)
{
enum bool linuxOrMingW = true;
}
else version(linux)
{
enum bool linuxOrMingW = true;
}
else
{
enum bool linuxOrMingW = false;
}
-----------------
module foo;
import myconfig;
static if(linuxOrMingW)
{
...
}
-----------------
More information about the Digitalmars-d
mailing list