annotate struct-array.c @ 2:bf65d90b8dc8

*** empty log message ***
author kinjo
date Mon, 28 Nov 2005 13:34:57 +0900
parents e59ebf6fe2b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
1 #include"my-stdio.h"
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
2
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
3 #define OBJECT_MAXNUM 10
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
4
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
5 #define _BUG
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
6
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
7 #ifdef _BUG
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
8 struct {
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
9 float j; // bug
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
10 int i;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
11 int k;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
12 int h;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
13 } a[OBJECT_MAXNUM];
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
14
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
15 #else
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
16
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
17 struct {
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
18 int i;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
19 int j;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
20 int k;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
21 int h;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
22 } a[OBJECT_MAXNUM];
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
23 #endif // _BUG
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
24
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
25 code
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
26 print_a(int i,code(*ret)(int),void *env)
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
27 {
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
28 if(i<OBJECT_MAXNUM){
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
29 #ifdef _BUG
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
30 printf("a[%d]: i=%d j=%f k=%d h=%d\n", i, a[i].i,a[i].j,a[i].k,a[i].h);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
31 #else
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
32 printf("a[%d]: i=%d j=%d k=%d h=%d\n", i, a[i].i,a[i].j,a[i].k,a[i].h);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
33 #endif
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
34 i++;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
35 goto print_a(i,ret,env);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
36 }
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
37 goto ret(0),env;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
38 }
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
39
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
40 code
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
41 init_a(int i,code(*ret)(int),void *env)
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
42 {
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
43 if(i<OBJECT_MAXNUM){
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
44 a[i].i=1;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
45 a[i].j=2;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
46 a[i].k=3;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
47 a[i].h=4;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
48 i++;
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
49 goto init_a(i,ret,env);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
50 }
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
51 goto print_a(0,ret,env);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
52 }
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
53
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
54 int
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
55 main()
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
56 {
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
57 goto init_a(0,return,environment);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
58 return(0);
e59ebf6fe2b0 Initial revision
kinjo
parents:
diff changeset
59 }