On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote:
If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ?

There's no ```release``` identifier and ```-debug``` switch and ```debug()``` condition are something else.

There's ```assert - Checks are being emitted for AssertExpressions```. With the exception for ```assert(0)```, those checks are omitted in release mode so this could be used for that purpose, right?

I don't think it would make much sense to have a `version(release)`, as there's really no such thing as a "release mode", or a "debug mode" either. -release is just a shorthand to disable certain features that you can also disable individually, and -debug means whatever you want it to mean.

Given that we have `version(assert)` and `version(D_NoBoundsChecks)`, it probably makes sense to also have equivalents to test if contracts are enabled, or if bounds checking is enabled only in safe code. Then you'd be able to cover all the bases that -release does. Sounds like a candidate for an enhancement request.

Reply via email to