Mercurial > hg > CbC > old > device
annotate test/tstdarg.c @ 751:c921670e2ce8
i64 continue... 64bit register
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 14 Nov 2010 04:56:02 +0900 |
parents | ebf5ae3f3863 |
children | 032dc03be02e |
rev | line source |
---|---|
285 | 1 |
2 | |
3 #include <stdio.h> | |
4 #include <stdarg.h> | |
5 | |
575 | 6 void |
285 | 7 var_args(char *numtypes, ...) |
8 { | |
9 int t; | |
10 int i; | |
11 float f; | |
12 double d; | |
13 long long l; | |
14 char *s; | |
15 va_list ap; | |
16 | |
17 va_start(ap,numtypes); | |
18 | |
19 while((t= *numtypes++)) { | |
20 if (t=='i') { | |
21 i = va_arg(ap,int); | |
427 | 22 printf("#0021:int arg: %d\n",i); |
741 | 23 #if 0 /* ‘float’ is promoted to ‘double’ when passed through ‘...’ */ |
285 | 24 } else if (t=='f') { |
25 f = va_arg(ap,float); | |
427 | 26 printf("#0025:float arg: %g\n",f); |
285 | 27 #endif |
28 } else if (t=='d') { | |
29 d = va_arg(ap,double); | |
427 | 30 printf("#0029:double arg: %g\n",d); |
285 | 31 } else if (t=='l') { |
32 l = va_arg(ap,long long); | |
427 | 33 printf("#0032:long long arg: %lld\n",l); |
285 | 34 } else if (t=='s') { |
35 s = va_arg(ap,char *); | |
427 | 36 printf("#0035:char *arg: %s\n",s); |
285 | 37 } else { |
38 s = va_arg(ap,char *); | |
427 | 39 printf("#0038:arg: error\n"); |
285 | 40 } |
41 } | |
42 } | |
43 | |
540 | 44 int |
285 | 45 main() |
46 { | |
47 | |
48 var_args("iiiiii",1,2,3,4,5,6); | |
49 var_args("llllll",(long long)1,(long long)2,(long long)3,(long long)4,(long long)5,(long long)6); | |
305
117baacd1ed0
stdarg powerpc passed except long long (macro problem)
kono
parents:
285
diff
changeset
|
50 #if 0 |
285 | 51 var_args("ffffff",(float)1,(float)2,(float)3,(float)4,(float)5,(float)6); |
305
117baacd1ed0
stdarg powerpc passed except long long (macro problem)
kono
parents:
285
diff
changeset
|
52 #endif |
285 | 53 var_args("dddddd",(double)1,(double)2,(double)3,(double)4,(double)5,(double)6); |
54 var_args("ssssss","1","2","3","4","5","6"); | |
306 | 55 return 0; |
285 | 56 } |