Is there a way I can define a manifest constant from the compiler command-line, like the -Dmacro option for C compilers?
Thread overview |
---|
March 27 Is there a -Dmacro like option for D compilers? | ||||
---|---|---|---|---|
| ||||
March 27 Re: Is there a -Dmacro like option for D compilers? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeremy | On Monday, 27 March 2023 at 22:22:26 UTC, Jeremy wrote: >Is there a way I can define a manifest constant from the compiler command-line, like the -Dmacro option for C compilers? You can do this way:
Unfortunatly there is not #ifndef, so in case you want to make sure FEATURE_A is not there you'll have to do:
or
For some reason they force us to be overly verbose Or it's possible to do it, but i don't know much more than this about (if you use ldc compiler, it's |
March 27 Re: Is there a -Dmacro like option for D compilers? | ||||
---|---|---|---|---|
| ||||
Posted in reply to ryuukk_ | I just remembered you can do something like this!
It's evaluated at compile time, so it's branchless! |
Copyright © 1999-2021 by the D Language Foundation