1 # returning structs from C
11 type :un9 = { { b } { s } }
12 type :st9 = { w, :un9 }
14 data $fmt1 = { b "t1: %s\n", b 0 }
15 data $fmt2 = { b "t2: %d\n", b 0 }
16 data $fmt3 = { b "t3: %f %d\n", b 0 }
17 data $fmt4 = { b "t4: %d %f\n", b 0 }
18 data $fmt5 = { b "t5: %f %lld\n", b 0 }
19 data $fmt6 = { b "t6: %s\n", b 0 }
20 data $fmt7 = { b "t7: %f %f\n", b 0 }
21 data $fmt8 = { b "t8: %d %d %d %d\n", b 0 }
22 data $fmt9 = { b "t9: %d %f\n", b 0 }
28 %i1 =w call $printf(l $fmt1, ..., l %r1)
32 %i2 =w call $printf(l $fmt2, ..., w %w2)
39 %i3 =w call $printf(l $fmt3, ..., d %p3, w %w3)
45 %i4 =w call $printf(l $fmt4, ..., w %w4, d %d4)
52 %i5 =w call $printf(l $fmt5, ..., d %d5, l %l5)
55 %i6 =w call $printf(l $fmt6, ..., l %r6)
62 %i7 =w call $printf(l $fmt7, ..., d %d71, d %d72)
72 %i8 =w call $printf(l $fmt8, ..., w %w81, w %w82, w %w83, w %w84)
79 %i9 =w call $printf(l $fmt9, ..., w %w9, d %d9)
87 # typedef struct { char t[17]; } st1;
88 # typedef struct { int i; } st2;
89 # typedef struct { float f; int i; } st3;
90 # typedef struct { int i; double d; } st4;
91 # typedef struct { float f; long l; } st5;
92 # typedef struct { char t[16]; } st6;
93 # typedef struct { float f; double d; } st7;
94 # typedef struct { int i[4]; } st8;
95 # typedef struct { int i; union { char c; float f; } u; } st9;
96 # extern void test(void);
97 # st1 t1() { return (st1){"abcdefghijklmnop"}; }
98 # st2 t2() { return (st2){2}; }
99 # st3 t3() { return (st3){3.0,30}; }
100 # st4 t4() { return (st4){4,-40}; }
101 # st5 t5() { return (st5){5.5,-55}; }
102 # st6 t6() { return (st6){"abcdefghijklmno"}; }
103 # st7 t7() { return (st7){7.77,77.7}; }
104 # st8 t8() { return (st8){-8,88,-888,8888}; }
105 # st9 t9() { return (st9){9,{.f=9.9}}; }
106 # int main() { test(); return 0; }
110 # t1: abcdefghijklmnop
115 # t6: abcdefghijklmno
116 # t7: 7.770000 77.700000
117 # t8: -8 88 -888 8888