There are a few options:

1. static if(audio)
2. version(audio)
3. if (audio)

It looks like you are trying to create the version(audio) semantic(if exists then use, else don't).

Ultimately, though, if you are trying to make a binary that can either use audio or not depending on where it is ran, you'll have to stick to using actual run time variables and probably be a bit more organized about it.

option 1 is the one I was shooting for. does the static if (audio) just check for the existence of audio, or does it also check to see if audio is true as well?


Yes, but it checks at compile time. So the code will be evaluated by the compiler and if audio is true, it will only compile in the code in the if block.

e.g,

    static if (audio) { do something }

will be identical, in the binary, to

    do something

if audio is true.

The static if is an if statement and works like any ordinary if statement, but since you are using static(known at compile time) information then static if can actually be computed/evaluated at compile time(since all the inputs are know and cannot be changed)

Reply via email to