Is there a -Dmacro like option for D compilers?

ryuukk_ ryuukk.dev at gmail.com
Mon Mar 27 22:42:40 UTC 2023


I just remembered you can do something like this!


```
import std.stdio;

enum FEATURE_A_AVAILABLE()
{
     version(FEATURE_A) return true;
     else return false;
}

void main()
{
     static if (!FEATURE_A_AVAILABLE)
     {
         writeln("feature A not available");
     }

}
```

It's evaluated at compile time, so it's branchless!


More information about the Digitalmars-d-learn mailing list