1: #include <stdio.h>
2:
3: /* Initilization of structure containing a union:
4: * "tstlgm.c" actually is illegal anyway, since the structure
5: * only has four entries. This file is more legal. One set of
6: * compiler fixes allow this to compile (even correctly).
7: */
8:
9: struct TEST {
10: int first;
11: int second;
12: union UTEST {
13: int u_int;
14: char *u_cptr;
15: int *u_iptr;
16: } third;
17: int fourth;
18: };
19:
20: struct TEST test[] = {
21: {0},
22: {1},
23: {1},
24: {1},
25: {1,2,3,4,5,6}, /* this is what makes it actually illegal */
26: {0},
27: {1,2,0,0},
28: {1,2,0,0},
29: {0,0,0,0},
30: {1}
31: };
32:
33: main()
34: {
35: int i;
36:
37: printf("Size of TEST structure = %d\n",sizeof(struct TEST));
38: printf("Size of structure test = %d\n",sizeof(test));
39:
40: for (i = 0; i < 10; ++i){
41: printf("Cycle %d ",i);
42: printf("First = %d\tSecond = %d\t",
43: test[i].first, test[i].second);
44: printf("Union third = %d\t", test[i].third.u_int);
45: printf("Fourth = %d\n", test[i].fourth);
46: }
47: }
Defined functions
main
defined in line
33;
never used
Defined variables
test
defined in line
20; used 5 times
Defined struct's
TEST
defined in line
9; used 4 times
Defined union's
UTEST
defined in line
12;
never used