Skip to content

Instantly share code, notes, and snippets.

@stefantalpalaru
Created December 21, 2019 09:50
Show Gist options
  • Save stefantalpalaru/0555e06b5ff8998be44370ed9612742a to your computer and use it in GitHub Desktop.
Save stefantalpalaru/0555e06b5ff8998be44370ed9612742a to your computer and use it in GitHub Desktop.
const nimStackTraceOverride {.strdefine.} = ""
when defined(nimStackTraceOverride):
import macros
macro importModuleFromString(s: static[string]): untyped =
if s == "true":
# empty command line definition
error("You need to specify the module's name with `-d:nimStackTraceOverride=yourModuleHere`")
result = newNimNode(nnkImportStmt).add(newIdentNode(s))
importModuleFromString(nimStackTraceOverride)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment