1 # returning structs from C
11 type :un9 = { { b } { s } }
12 type :st9 = { w, :un9 }
14 type :stb = { b, b, s }
16 data $fmt1 = { b "t1: %s\n", b 0 }
17 data $fmt2 = { b "t2: %d\n", b 0 }
18 data $fmt3 = { b "t3: %f %d\n", b 0 }
19 data $fmt4 = { b "t4: %d %f\n", b 0 }
20 data $fmt5 = { b "t5: %f %lld\n", b 0 }
21 data $fmt6 = { b "t6: %s\n", b 0 }
22 data $fmt7 = { b "t7: %f %f\n", b 0 }
23 data $fmt8 = { b "t8: %d %d %d %d\n", b 0 }
24 data $fmt9 = { b "t9: %d %f\n", b 0 }
25 data $fmta = { b "ta: %d %f\n", b 0 }
26 data $fmtb = { b "tb: %d %d %f\n", b 0 }
32 %i1 =w call $printf(l $fmt1, ..., l %r1)
36 %i2 =w call $printf(l $fmt2, ..., w %w2)
43 %i3 =w call $printf(l $fmt3, ..., d %p3, w %w3)
49 %i4 =w call $printf(l $fmt4, ..., w %w4, d %d4)
56 %i5 =w call $printf(l $fmt5, ..., d %d5, l %l5)
59 %i6 =w call $printf(l $fmt6, ..., l %r6)
66 %i7 =w call $printf(l $fmt7, ..., d %d71, d %d72)
76 %i8 =w call $printf(l $fmt8, ..., w %w81, w %w82, w %w83, w %w84)
83 %i9 =w call $printf(l $fmt9, ..., w %w9, d %d9)
90 %ia =w call $printf(l $fmta, ..., w %wa, d %da)
99 %ib =w call $printf(l $fmtb, ..., w %w0b, w %w1b, d %db)
106 # typedef struct { char t[17]; } st1;
107 # typedef struct { int i; } st2;
108 # typedef struct { float f; int i; } st3;
109 # typedef struct { int i; double d; } st4;
110 # typedef struct { float f; long l; } st5;
111 # typedef struct { char t[16]; } st6;
112 # typedef struct { float f; double d; } st7;
113 # typedef struct { int i[4]; } st8;
114 # typedef struct { int i; union { char c; float f; } u; } st9;
115 # typedef struct { char c; float f; } sta;
116 # typedef struct { char c0, c1; float f; } stb;
117 # extern void test(void);
118 # st1 t1() { return (st1){"abcdefghijklmnop"}; }
119 # st2 t2() { return (st2){2}; }
120 # st3 t3() { return (st3){3.0,30}; }
121 # st4 t4() { return (st4){4,-40}; }
122 # st5 t5() { return (st5){5.5,-55}; }
123 # st6 t6() { return (st6){"abcdefghijklmno"}; }
124 # st7 t7() { return (st7){7.77,77.7}; }
125 # st8 t8() { return (st8){-8,88,-888,8888}; }
126 # st9 t9() { return (st9){9,{.f=9.9}}; }
127 # sta ta() { return (sta){-10,10.1}; }
128 # stb tb() { return (stb){-1,11,11.11}; }
129 # int main() { test(); return 0; }
133 # t1: abcdefghijklmnop
138 # t6: abcdefghijklmno
139 # t7: 7.770000 77.700000
140 # t8: -8 88 -888 8888
143 # tb: -1 11 11.110000