Conditional compilation: Which version identifier for release code ? version(assert) ?

wjoe invalid at example.com
Thu Aug 5 10:43:01 UTC 2021


On Thursday, 5 August 2021 at 10:08:12 UTC, Mike Parker wrote:
> On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote:
> 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.

Thanks, that helps a lot.

I agree about release and debug modes. It got stuck in my mind 
when I used Visual Studio years ago which, at least at the time, 
created a Debug and Release configuration by default.

Could you elaborate on ```version(assert)``` a bit more, please ? 
Like I compiled with ```-release, -g``` and without the 2 options 
but the ```assert``` branch was always taken. Could it be that 
```-unittest``` has something to do with it ?



More information about the Digitalmars-d-learn mailing list