www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - -debug question

reply forkit <forkit gmail.com> writes:
I have a line of code, that I do NOT want executed when -debug is 
passed in.

enforce(!exists(fname), "Oop! That file already exists!");

Is this even possible? (with using -version ..)
Jan 20 2022
next sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 1/20/22 9:07 PM, forkit wrote:
 I have a line of code, that I do NOT want executed when -debug is passed 
 in.
 
 enforce(!exists(fname), "Oop! That file already exists!");
 
 Is this even possible? (with using -version ..)
 
`debug` is like a `version` block. ```d debug {} else { // code that runs when -debug is not present } ``` -Steve
Jan 20 2022
parent forkit <forkit gmail.com> writes:
On Friday, 21 January 2022 at 02:10:34 UTC, Steven Schveighoffer 
wrote:

thanks Steven (and Ali too).
Jan 20 2022
prev sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 1/20/22 18:07, forkit wrote:
 I have a line of code, that I do NOT want executed when -debug is passed 
 in.
 
 enforce(!exists(fname), "Oop! That file already exists!");
 
 Is this even possible? (with using -version ..)
 
The following should do it: debug {} else { foo(); } Ali
Jan 20 2022