No, can not access the const with constructed name inside the macro 
    
    
    import macros
    
    const CX = 7
    
    proc genVar(c: static[string]): NimNode {.compiletime.} =
      result = newNimNode(nnkStmtList)
      var
        section = newNimNode(nnkVarSection)
        constDef = newNimNode(nnkIdentDefs)
      constDef.add(newIdentNode("myvar"))
      constDef.add(newEmptyNode())
      constDef.add(newIdentNode("C" & $c))
      section.add(constDef)
      result.add(section)
    
    macro t(s: static[string]): typed =
      genVar($s)
      if myVar == 7:
        echo "GREAT"
    
    t("X")
    

Reply via email to