comparison test/vararg4.d @ 70:fb265a6efea1 trunk

[svn r74] Fixed passing types with different alignment to D-style variadic functions. Fixed casting integer to pointer.
author lindquist
date Sun, 28 Oct 2007 19:33:50 +0100
parents
children d9d5d59873d8
comparison
equal deleted inserted replaced
69:2b5a2eaa88be 70:fb265a6efea1
1 module vararg4;
2 import std.stdarg;
3
4 void vafunc(...)
5 {
6 foreach(i,v; _arguments) {
7 if (typeid(byte) == v) {
8 printf("byte(%d)\n", va_arg!(byte)(_argptr));
9 }
10 else if (typeid(short) == v) {
11 printf("short(%d)\n", va_arg!(short)(_argptr));
12 }
13 else if (typeid(int) == v) {
14 printf("int(%d)\n", va_arg!(int)(_argptr));
15 }
16 else if (typeid(long) == v) {
17 printf("long(%ld)\n", va_arg!(long)(_argptr));
18 }
19 else if (typeid(float) == v) {
20 printf("float(%f)\n", va_arg!(float)(_argptr));
21 }
22 else if (typeid(double) == v) {
23 printf("double(%f)\n", va_arg!(double)(_argptr));
24 }
25 else if (typeid(real) == v) {
26 printf("real(%f)\n", va_arg!(real)(_argptr));
27 }
28 else
29 assert(0, "unsupported type");
30 }
31 }
32
33 void main()
34 {
35 vafunc(byte.max,short.max,1,2,3,4L,5.0f,6.0,cast(real)7);
36 }