Version very simple?
David Nadlinger
see at klickverbot.at
Sun Feb 27 07:18:29 PST 2011
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
More information about the Digitalmars-d-learn
mailing list