Version 0.18.0 of nim does not seem to recognize defined symbol values:
The source named checkCTsym.nim is:
when CTS==yes:
echo "yes"
else:
echo "no"
The compile command is:
nim c -r -d:CTS=yes checkCTsym
The error message is: > checkCTsym.nim(1, 6) Error: undeclared identifier: 'CTS'
The nim version is:
Nim Compiler Version 0.18.0 [Linux: amd64]
Copyright (c) 2006-2018 by Andreas Rumpf
git hash: 855956bf617f68ac0be3717329e9e1181e5dc0c6
active boot switches: -d:release
The What silly thing am I doing wrong??
I have already tried quoting the yes and using : instead of = in the compile command.
BTW the Nim Compiler User Guide says:
Compile time symbols
Through the -d:x or --define:x switch you can define compile time symbols for conditional compilation. The defined switches can be checked in source code with the when statement and defined proc. The typical use of this switch is to enable builds in release mode (-d:release) where certain safety checks are omitted for better performance. Another common use is the -d:ssl switch to activate SSL sockets.
Additionally, you may pass a value along with the symbol: -d:x=y which may be used in conjunction with the compile time define pragmas to override symbols during build time.
Compile time symbols are completely case insensitive and underscores are ignored too. --define:FOO and --define:foo are identical.
you can use
when defined(CTS): # if the CTS value is "true" or "false"
...
or
const CTS {.strdefine.} = "default_value"
when CTS=="yes":
...
currently there is nothing like when getValue(CTS) == "xxx" and conditional symbols are not 'normal symbols'