Static if on release build

b4s1l3 b52.temp at gmx.com
Fri Oct 20 03:29:10 UTC 2017


On Friday, 20 October 2017 at 02:36:37 UTC, Fra Mecca wrote:
> I can't find any documentation regarding conditional 
> compilation in release and debug mode.
>
> I have read the page regarding the topicon dlang.org but adding 
> the snippet below makes no difference when compiling with dub 
> -b release
> {
> version(full) {
>  //do something
> } else {
> //do something else
> }
>
> How can I produce a release version with different parameters 
> from debug using dub and static if's?

The most close compile condition is

version(assert)
{
     // build for testing
}
else
{
     // build for release
}

see https://dlang.org/spec/version.html#predefined-versions:

"assert	Checks are being emitted for AssertExpressions"

And at the same time

https://dlang.org/dmd-linux.html#switch-release

"compile release version, which means not emitting run-time 
checks for contracts and asserts. Array bounds checking is not 
done for system and trusted functions, and assertion failures are 
undefined behaviour."


More information about the Digitalmars-d-learn mailing list