Created
February 18, 2015 18:03
-
-
Save PhilipWitte/f094f8894df2d0003b98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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