Using two flags in conditonal compilation (version)

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 25 13:30:11 PDT 2014


Danyal Zia:

> Is there a way to check both versions at the same time? (I 
> can't seem to find the solution through google, sorry)

This is close to being the best solution in D (untested):

version(DigitalMars) enum myMars = true; else enum myMars = false;
version(LDC) enum myLdc = true; else enum myLdc = false;
enum myMarsOrLdc = myMars || myLdc;

static if (myMarsOrLdc) {
     ...
} else {
     ...
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list