comparison tangotests/vararg2.d @ 163:a8cd9bc1021a trunk

[svn r179] lots and lots of fixes, much more of tango now compiles/works.
author lindquist
date Mon, 05 May 2008 07:36:29 +0200
parents
children
comparison
equal deleted inserted replaced
162:1856c62af24b 163:a8cd9bc1021a
1 module tangotests.vararg2;
2
3 extern(C) int printf(char*, ...);
4
5 import tango.core.Vararg;
6
7 void main()
8 {
9 func(0xf00, 1, " ", 2, " ", 3, "\n", 0.3, "\n");
10 }
11
12 void func(int foo, ...)
13 {
14 foreach(t; _arguments)
15 {
16 if (t == typeid(char[]))
17 {
18 char[] str = va_arg!(char[])(_argptr);
19 printf("%.*s", str.length, str.ptr);
20 }
21 else if (t == typeid(int))
22 {
23 printf("%d", va_arg!(int)(_argptr));
24 }
25 else if (t == typeid(float))
26 {
27 printf("%f", va_arg!(float)(_argptr));
28 }
29 else if (t == typeid(double))
30 {
31 printf("%f", va_arg!(double)(_argptr));
32 }
33 else if (t == typeid(real))
34 {
35 printf("%f", va_arg!(real)(_argptr));
36 }
37 else
38 {
39 assert(0, "not int");
40 }
41 }
42 }