tcvarargs.nim 433 B

123456789101112131415161718192021222324252627282930313233343536
  1. discard """
  2. output: '''17
  3. 17
  4. 17
  5. 17
  6. 17
  7. 17
  8. '''
  9. """
  10. # bug #1593
  11. {.emit: """
  12. #include <stdarg.h>
  13. #include <stdio.h>
  14. void foo(int n, ...) {
  15. NI64 k;
  16. int i;
  17. va_list argp;
  18. va_start(argp, n);
  19. for (i = 1; i <= n; i++) {
  20. k = va_arg(argp, NI64);
  21. printf("%lld\n", (long long)k);
  22. }
  23. va_end(argp);
  24. }
  25. """.}
  26. proc foo(x: cint) {.importc, varargs, nodecl.}
  27. proc main() =
  28. const k = 17'i64
  29. foo(6, k, k, k, k, k, k)
  30. main()