www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Static if on release build

reply Fra Mecca <me francescomecca.eu> writes:
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?
Oct 19 2017
next sibling parent bauss <jj_1337 live.dk> writes:
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?
Take a look at this: https://dlang.org/spec/version.html#DebugCondition
Oct 19 2017
prev sibling next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 20/10/2017 3:36 AM, 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?
Well yeah... full doesn't exist[0]. If debug is turned on: debug { } else { } That else isn't for 'release'. Release turns on optimizations in the compiler and disables a few other things like asserts. If you want to specify a version at the command line use ``-version=MyVersion``. For a debug identifier use ``--debug=MyDebug`` and yes, debug conditions can have identifiers like versions require. For dub you can specify it via ``versions`` and ``debugVersions``. [0] https://dlang.org/spec/version.html [1] http://code.dlang.org/package-format?lang=json
Oct 19 2017
prev sibling next sibling parent b4s1l3 <b52.temp gmx.com> writes:
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."
Oct 19 2017
prev sibling parent Guillaume Piolat <first.last gmail.com> writes:
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?
Note thatwith D compilers -debug and -release are not opposed to each other. A program can have both flags, or none.
Oct 21 2017