Print debugging statement: Difference between revisions

m
Changed first example to look like last one.
m (Changed first example to look like last one.)
Line 464:
The conditional activation is done using a “when” statement. Here is an example:
<lang Nim>when defined(debug):
echo "Debugging info: ",$1 x, "$2 $3".format(x, y, " ", z)</lang>
When compiling, if nothing is specified, no code is generated to display the debugging information. If we want to generate the debug statements, we have to specify <code>-d:debug</code> when compiling, for instance if the file is named “example.nim”: <code>nim c -d:debug example.nim</code>. Note that the name “debug” has been chosen as an example but maybe any valid Nim identifier not already used. This allows to use different flags according to what we want to debug.
 
Anonymous user