Mercurial > hg > CbC > old > device
annotate test/tmp11.c @ 928:96c53f76b360
fix
author | kono |
---|---|
date | Sun, 13 Apr 2014 10:21:40 +0900 |
parents | d712ee10feb7 |
children |
rev | line source |
---|---|
467 | 1 int printf(const char *format, ...); |
2 | |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
3 typedef struct nametable { |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
4 char *nm; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
5 int sc,ty,dsp; } NMTBL; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
6 NMTBL *a; |
832 | 7 NMTBL f; |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
8 |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
9 NMTBL * |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
10 test2(char *n) { |
896
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
11 printf("#0010:s %s\n",n); |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
12 return a; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
13 } |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
14 |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
15 int |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
16 test0(int a,int b,int c) { |
896
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
17 printf("#0016:a %d b %d c %d\n",a,b,c); |
172 | 18 return 0; |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
19 } |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
20 |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
21 int |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
22 test1(a,b,c) |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
23 int a,b;int c; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
24 { |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
25 return test0(a,b,c); |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
26 } |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
27 |
832 | 28 int heap[10]; |
29 | |
30 #define ncaddr(e) (*(NMTBL**)&heap[e+2]) | |
31 | |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
32 int |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
33 main() |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
34 { |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
35 int d; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
36 NMTBL *b; |
832 | 37 f.nm = "_name"; |
38 a = &f; | |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
39 b = test2("test"); |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
40 d = test1(1,2,3); |
896
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
41 printf("#0040:return %d\n",d); |
832 | 42 |
43 NMTBL **p = (NMTBL**)&heap[2]; | |
44 *p = &f; | |
45 b = &f; | |
46 int e = 0; | |
896
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
47 printf("#0046:f.nm %s\n",f.nm); |
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
48 printf("#0047:b->nm %s\n",b->nm); |
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
49 printf("#0048:(*p)->nm %s\n",(*p)->nm); |
d712ee10feb7
local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
832
diff
changeset
|
50 printf("#0049:ncaddr(e)->nm %s\n",ncaddr(e)->nm); |
832 | 51 |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
52 return d; |
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff
changeset
|
53 } |
832 | 54 |
55 /* end */ |