7 ms·
Check out https://github.com/D-Programming-Language/phobos/blob/master/std/file.d https://github.com/D-Programming-Language/phobos/blob/master... at line 33 and
by WalterBright 12y ago
Check out https://github.com/D-Programming-Language/phobos/blob/master/std/file.d https://github.com/D-Programming-Language/phobos/blob/master... at line 33 and on. You'll see:
version (Windows)
{
...
}
etc. For the specification on how this works:
http://dlang.org/version.html http://dlang.org/version.html
The salient point is that conditional compilation in D is not text based, it is AST based. Furthermore, for 'static if', the conditional expression has access to the full symbol table and power of the D language - it is not a separate preprocessor language with its own rules and separate symbol table.
- ridiculous_fish 12y agoThank you for the reply. That's very elegant!
- deleted 12y ago[deleted]
- ape4 12y agoCan it do more complex ifdefs - with or's and and's etc?
- WalterBright 12y ago'static if' can - it has full access to the language.