Skip to content

Instantly share code, notes, and snippets.

@PhilipWitte
Created February 18, 2015 18:03
Show Gist options
  • Save PhilipWitte/f094f8894df2d0003b98 to your computer and use it in GitHub Desktop.
Save PhilipWitte/f094f8894df2d0003b98 to your computer and use it in GitHub Desktop.
import macros
macro makeEmitPrag(lit:static[string]): stmt =
result = newStmtList().add(
newNimNode(nnkPragma).add(
newNimNode(nnkExprColonExpr).add(
newIdentNode("emit"),
newStrLitNode(lit)
)
)
)
makeEmitPrag("int i = 123;")
var i {.importc.}: cint
echo i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment