source: doc/proposals/modules-gen-hdr/hello/c.src.c@ 295ed2d1

Last change on this file since 295ed2d1 was b28ce93, checked in by Michael Brooks <mlbrooks@…>, 3 months ago

Add POC illustrating generating headers from compile units

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#import auto b
2#import static helper
3
4//# @
5struct c {
6 struct b z;
7 struct a q;
8};
9
10//# $v
11struct a glb_ca = { 40 };
12
13//# $v
14struct b glb_cb = { { 50 } };
15
16//# $v
17struct c glb_cc = { { { 60 } }, { 70 } };
18
19//# $f
20void f_c( struct c p ) {
21 int printf( const char *, ... ); // scaffold
22 printf( "f_c( c{ b{ a{ %d } }, a{ %d } } )\n", p.z.y.x, p.q.x );
23 printf( "\tglb_a == a{ %d }\n", glb_a.x);
24 printf( "\tglb_ba == a{ %d }\n", glb_ba.x);
25 printf( "\tglb_bb == b{ a{ %d } }\n", glb_bb.y.x );
26 printf( "\tglb_ca == a{ %d }\n", glb_ca.x);
27 printf( "\tglb_cb == b{ a{ %d } }\n", glb_cb.y.x );
28 printf( "\tglb_cc == c{ b{ a{ %d } }, a{ %d } }\n", glb_cc.z.y.x, glb_cc.q.x );
29 glb_a.x += 1;
30 glb_ba.x += 1;
31 glb_bb.y.x += 1;
32 p.z.y.x += 1;
33 p.q.x += 1;
34 f_b( p.z );
35 f_a( p.q );
36 help(); // accept => a's `#import static helper` independent from here
37 printf( "f_c end\n" );
38}
39
40//# $f
41int main() {
42 struct a la = { 500 };
43 struct b lb = { { 600 } };
44 struct c lc = { { { 700 } }, { 800 } };
45 f_a(la);
46 f_b(lb);
47 f_c(lc);
48}
Note: See TracBrowser for help on using the repository browser.