Last active
August 29, 2015 14:20
-
-
Save PhilipWitte/3bb61b3b9fdb0a7cd9c9 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 | |
{.emit:""" | |
void foobar(int i, ...) { | |
va_list args; | |
int j; | |
printf("Count: %i\n", i); | |
va_start(args, i); | |
for (j = 0; j < i; j++) { | |
int x = va_arg(args, int); | |
printf("%i\n", x); | |
} | |
va_end(args); | |
} | |
""".} | |
proc foobar(i:cint) {.importc varargs.} | |
macro barfoo(nums:varargs[cint]): stmt = | |
result = quote do: | |
foobar(`nums`.len.cint) | |
for n in nums.children: | |
result[0].add(n) | |
barfoo(1, 2, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment