On 2/27/11 3:52 PM, simendsjo wrote:
I'm having some problems grokking version.

How would I translate this simple C macro?
#if !defined(IDENT) || !defined(IDENT2)

You are facing a quite common question, with the answer being that there is no simpler way to do this, at least that I know of.

This has to do with both the stage at which version blocks are parsed internally, and with Walter taking a defensive stance on the power of version statements because he feels that the typical C preprocessor constructs are often a source for confusion (sorry if I misquoted you there).

If you need more complex version conditions, however, you could consider mapping versions to manifest constants and using static ifs like this:

version (foo) {
   enum version_foo = true;
} else {
   enum version_foo = false;
}

static if (version_foo || (version_bar && !version_baz) ) {
   …
} else {
   …
}


David

Reply via email to