Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a line of code in debug mode only in Nim?

I have a line of code that I want to run in debug mode but not in release mode. Is there a way to automatically handle this?

like image 637
Imran Avatar asked Mar 07 '23 22:03

Imran


1 Answers

when not defined(release):
  echo "Debug"

Compiler options set with -d, like -d:release, can be used in the program using the defined proc: https://nim-lang.org/docs/system.html#defined,untyped

Since it's available at compile-time we can use a when (compile-time if) instead of a regular runtime if.

like image 57
def- Avatar answered May 24 '23 21:05

def-