Hi. I've got exception:
macro init*(backend: static[int]): typed =
when backend == 1: # excepted with message: "cannot evaluate at compile time: backend"
discard
else:
discard
init 1
Parameters and result of the macros are evaluating before compilation, no?
Thanks.
@r3d9u11 you should use "if" instead of "when" because macro is already executed at compile-time
Change when to if.
@Yardanico @data-man thanks for hint, but I can't use if statement.
inside when statement I'm calling another macros, who doing import of different packages (due to backend). and it can be used only with when statement.
template init*(backend: static[int]): typed =
when backend == 1: # excepted with message: "cannot evaluate at compile time: backend"
discard
else:
discard
init 1
@data-man many thanks, this works! I should use templates instead of macros in this task.