1 struct sa {
2 int a1, a2;
3 } a;
4
5 struct sb {
6 int b1[3];
7 struct sa b2;
8 struct sa b3;
9 int b4[3];
10 };
11
12 #pragma echo "Consecutive elements in arrays\n"
13 struct sb sb1 = {
14 0, 0, 0, // b1
15 { .a1 = 4}, // b2
16 };
17
18 #pragma echo "Consecutive elements in structures\n"
19 struct sb sb2 = {
20 {0, 0, 0,}, // b1
21 1, 2, // b2
22 { .a1 = 4}, // b3
23 };
24
25 #pragma echo "Missing elements in arrays and structures\n"
26 struct sb sb3 = {
27 {0, 0,}, // b1
28 {1, }, // b2
29 { .a1 = 4}, // b3
30 };
31
32 #pragma echo "With optional comma\n"
33 struct sb sb4 = {
34 {1, 2, 3,} , // b1
35 {4, 5, }, // b2
36 { .a1 = 4}, // b3
37 };
38
39 #pragma echo "Without optional comma\n"
40 struct sb sb5 = {
41 {1, 2, 3} , // b1
42 {4, 5}, // b2
43 { .a1 = 4}, // b3
44 };
45
46 #pragma echo "Set current element with structure (w opt comma)\n"
47 struct sb sb6 = {
48 .b2 = {1,},
49 { .a1 = 4}, // b3
50 };
51
52 #pragma echo "Set current element with structure\n"
53 struct sb sb7 = {
54 .b2 = {1},
55 { .a1 = 4}, // b3
56 };
57
58 #pragma echo "Set current element with structure element\n"
59 struct sb sb8 = {
60 .b2.a2 = 1,
61 { .a1 = 4}, // b3
62 };
63
64
65 #pragma echo "Set current element in array\n"
66 struct sb sb10 = {
67 .b1 = {2,},
68 { .a1 = 4}, // b2
69 { .a1 = 4}, // b3
70 };
71
72 #pragma echo "Set current element to structure element and move to array\n"
73 struct sb sb11 = {
74 .b3.a1 = 4, // b3
75 5, // b3
76 { [2] = 8 },
77 };
78
79
80 #pragma echo "Set current element in array element\n"
81 struct sb sb12 = {
82 .b1[1] = 2,
83 3,
84 { .a1 = 4}, // b2
85 { .a1 = 4}, // b3
86 };
87
88
89 void
func1(void)90 func1(void)
91 {
92 #pragma echo "Initialize structure with an element of that type\n"
93 // (must be auto)
94 struct sb sb13 = {
95 {0}, // b1
96 a, // b2
97 { .a1 = 4}, // b3
98 };
99 }
100
101 #pragma echo "Solaris example\n"
102 typedef union fs_func {
103 int (*error)();
104 } fs_func_p;
105
106 typedef struct fs_operation_def {
107 char *name;
108 fs_func_p func;
109 } fs_operation_def_t;
110
111 static int
devinit(int fstype,char * name)112 devinit(int fstype, char *name)
113 {
114 static const fs_operation_def_t dev_vfsops_tbl[] = {
115 "mount", { .error = 0 },
116 };
117 }
118
119