Mercurial > projects > dstress
comparison run/mini/vararg1.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1627:e1b954780837 | 1628:c6ef09dfba4d |
---|---|
1 module vararg1; | |
2 | |
3 version(Tango) | |
4 { | |
5 import tango.core.Vararg; | |
6 } | |
7 else | |
8 { | |
9 import std.c.stdarg; | |
10 } | |
11 | |
12 extern(C) int add(int n, ...) | |
13 { | |
14 va_list ap=void; | |
15 va_start(ap, n); | |
16 int r; | |
17 for (int i=0; i<n; i++) | |
18 r += va_arg!(int)(ap); | |
19 va_end(ap); | |
20 return r; | |
21 } | |
22 | |
23 void main() | |
24 { | |
25 int i = add(4, 1,2,3,4); | |
26 assert(i == 10); | |
27 } |