Index: doc/proposals/modules-gen-hdr/README
===================================================================
--- doc/proposals/modules-gen-hdr/README	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/README	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,126 @@
+cfa-cppp - CForall pre-preprocessor
+
+POC deriving header files from a compile unit's source.
+
+Input: Aet of interdependent *.src.c files, each written as if header files are not a consideration (Java-style, definitions only), annotated with both the language additions and POC scaffolding listed below.
+
+Key Intermediate: For each %.src.c input, %.tdcl.h, %.defn.h, %.impl.c, containing relevant true-cpp #include directives of each other, such that the resulting classic-C build of a self-sufficient set of *.impl.c files gives the demo's Output.
+
+Output: Linked and running program
+
+Terminology
+- shred: "Shredding foo.src.c" means producing the "foo" Key Intermediates from the "foo" Input.
+- vicious: cyclic dependency that cannot be bootstrapped with the tools under POC
+
+
+To run:
+    if grep -q 'cfa-cppp' Makefile; then echo ok; else echo Wrong folder; fi;
+    make                                    # expect success
+    hello/a.out                             # expect log of fcn calls and glb-var vals
+    coop/a.out                              # expect log of chickens hatching from eggs
+    akwd-val-trans/a.out                    # expect four coop-like logs of a/b calls
+    make err-vicious/a.out                  # expect failure after shredding done
+    make clean                              # expect success
+    make hello/a.out CFLAGS=-DERR1          # expect failure after shredding done
+    grep -rE 'ERR[0-9]*' --include=*.src.c  # repeat prev -DERR act / do "manual" steps
+                                            # on resulting grep hits
+
+
+Demos are
+- (`err-` means "build is expected to fail")
+- hello: valid hello-world scenario with transitive dependency
+  - linear (bottom-up) build order would be fine
+- coop (chickens and eggs): valid circular dependency, resolved with `import auto &`
+  - "as much mutual recursion as I can cram, without going vicious"
+- vicious: the bridge too far, that coop resisted crossing, a:tdefs <-> b:tdefs
+  - requires an out-of-scope user's recourse, like multiple manual header fragments
+  - there does not exist a C-valid order of each module's offerings obtainable by ordering based on only offering sort (e.g. type definition, value declaration) and compile unit
+  - would never arise as real C code, without a split like one compile unit implementing two headers
+  - key difficulty: each side has a type definition that embeds a type defined on the opposite side
+- typeof: valid cicular dependency, its poential hiding in typeof
+  - b:vdefs -> a:tdefs -> b:vdecls
+- vicious-typeof: a vicious-cycle potential hiding in typeof, a:vdecls <-> b:vdecls
+  - comments under 'vicious' apply
+  - (including) expect recourse like multiple manual header fragments to resolve
+- vicious*/recourse-classic
+- vicious*/recourse-proposed
+
+
+In scope
+- module-level export vs private
+- automatically handle circular dependency  (demos: valid=coop invalid=err-vicious)
+- ordered dependency with transitive "re-export" (demo: hello)
+- separate compilation
+- structs, functions and global variables
+
+Out of Scope
+- (though believed not deal breakers for this proposal)
+- quality error messages
+- private struct fields, friends
+- illustrating how to set up a build (current Makefile is "get it to work")
+- crawling imports ("first-time gcc -MMD"), determining a build order
+- interaction of these modules with preexsting CFA features (current demos are C)
+- extracting shred-relevant information from C source (mocked up with scaffolding below)
+- C preprocessor integration: exporting a macro, ifdef'ing a #import
+- user's recourse for situations where headers are not inferrable
+- typedefs
+- controling visibility of types (equiv. choosing to put a struct in *.h vs *.c)
+- proffering implementation (equiv. function bodies in the header, like for static-inline)
+- rejecting attempt to offer something public that can't be understood without seeing something private
+- relaxing declare before use
+- legacy integration (demo uses printf/exit as loose declarations, main as "just define it")
+- linker control (demo dumps all exports into one linker namespace)
+
+
+Language additions modelled
+- (The proposal is to include nicer versions of these placeholders to CFA)
+- module imports (#import), where `foo` corresponds with foo.c; one of:
+- `#import static foo`: this implementation depends on foo's interface
+  - most common, equivaluent of #include in *.c
+- `#import auto & foo`: above, plus this interface mentions types from foo's interface without relying on size information
+  - relevant limitation is you can't nest those types inside types defined here
+  - it's a recourse for breaking a "normal" include cycle
+  - syntax parallels `forall T &` emphasizing you get enough to define functions that take imported types by reference, but not by value
+  - uncommon, equiv. replacing #include with a type forward declaration or giving *.fwd.h)
+- `#import auto foo`: above, plus this interface has unlimited access to foo's interface (quite common, equiv. #include in *.h)
+
+Scaffolding for the POC
+- (The proposal is to have better compile-time analysis, making these elements unnecessary)
+- No single-line definitions allowed
+- The first line of every user-given definition is a valid declaration, with its semicolon removed and an open-curly added
+- Every user-given definition is preceded, on the adjacent line, by a `//#` directive, which is the appropriate one of:
+  - `@` for an exported type
+  - `$f` for an exported function
+  - `$v` for an exported variable
+  - `-` for anything static
+- Generally, abide with the shredder being brittle on whitespace
+
+Choice: semantics of transitive import
+- Option A: To import+export a depended-upon module means re-exporting both its types and its values (functions, variables)
+  - Benefit: the typical basic application of C headers works this way
+- Option B: To import+export a depended-upon module means re-exporting only its types
+  - I'll use those types types in my exported declarations
+  - by importing me, you'll get those types so that you can use my declarations
+  - if you also want its values, you'll need to import them yourself
+  - Benefit: gives importers a tidier symbol table; you get implicitly only what you actually need
+- Incomplete Option A used in demo:  You re-export values only with `import auto M`, but not with `import auto & M`.
+  - This association is unnecessary mental complexity for a user.
+  - To do either a clean option A or B requires
+    - adding a third header flavour (a further split of .defn.h)
+    - furthermore, option A probably needs the rules for desugaring #import into #include to become transitive
+  - Left KISS / "common denominator" here
+  - Present-state workaround to achieve full Option A: Extra import in demo `akwd-val-trans/over_a.src.c`
+  - No option-B mockup available from present state because decision "`import auto M` re-exports values" means present state does exports that option B does not want
+
+Eventual implementation remark
+- To extract shred-relevant information from C source...
+- For %.c -> %.tdcl.h
+  - Ignore imports
+  - Need a limp-mode parser that does not differentiate types from identifiers
+  - It only has to produce the list of type names (non-recursively) exported, i.e. infer the `//# @` annotations
+- For %.c -> {%.defn.h, %.impl.c}
+  - On seeing `import auto foo` (or `import auto & foo`), pre-load the parser's type/id table as if `import auto & foo`, i.e. recursively consult imports, in limp mode, stopping upon a cycle (like #pragma once).
+  - It's not necessary to know information in foo.defn.h to shred % accurately.
+  - Today's CFA parser works and is sufficient (though overkill)
+  - Parsing here only needs to enable extracting a declaration from its definition.
+  - User errors, like, "You tried to pass an incomplete type by value," can come out later, while compiling %.impl.c.
Index: doc/proposals/modules-gen-hdr/akwd-val-trans/a.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/akwd-val-trans/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/akwd-val-trans/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,14 @@
+#import auto & b
+
+//# @
+struct a_t {
+    struct b_t * b;
+};
+
+//# $f
+void a( struct a_t * p, int depth ) {
+        int printf( const char *, ... );  // scaffold
+    if (depth < 0) return;
+    printf( "a %p %d\n", p, depth );
+    b( p->b, depth-1 );
+}
Index: doc/proposals/modules-gen-hdr/akwd-val-trans/b.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/akwd-val-trans/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/akwd-val-trans/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,16 @@
+#import auto a
+
+//# @
+struct b_t {
+    // embedding is really a tack-on here; tested in coop
+    // but it justifies the aymmetric a/b imports
+    struct a_t a; // not a pointer
+};
+
+//# $f
+void b( struct b_t * p, int depth ) {
+        int printf( const char *, ... );  // scaffold
+    if (depth <= 0) return;
+    printf( "b %p %d\n", p, depth );
+    a( & p->a, depth-1 );
+}
Index: doc/proposals/modules-gen-hdr/akwd-val-trans/main.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/akwd-val-trans/main.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/akwd-val-trans/main.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,11 @@
+#import static over_a
+#import static over_b
+
+//# $f
+int main() {
+        int printf( const char *, ... );  // scaffold
+    struct b_t x;
+    x.a.b = & x;
+    over_a( & x.a, 5 );
+    over_b( & x, 5 );
+}
Index: doc/proposals/modules-gen-hdr/akwd-val-trans/over_a.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/akwd-val-trans/over_a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/akwd-val-trans/over_a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,17 @@
+// in full-option-A transitive semantics, includes b's functions
+#import auto a
+
+// awkward but necessary here, unnecessary in full-option-A transitive semantics
+// MANUAL step as ERR1: comment out the import
+//   (manual becuase can't ifdef an import)
+//   scaffold note: leave space after comment token, so `// #`, not `//#`
+#import static b
+
+//# $f
+void over_a( struct a_t * p, int depth ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "over_a -> a\n" );
+    a( p, depth);
+    printf( "over_a -> b\n" );
+    b( p->b, depth);
+}
Index: doc/proposals/modules-gen-hdr/akwd-val-trans/over_b.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/akwd-val-trans/over_b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/akwd-val-trans/over_b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,15 @@
+// in full-option-A transitive semantics and demo-hybrid, includes a's functions
+#import auto b
+
+// necessary only in full-option-B transitive semantics
+// (unnecessary in demo's awkward hybrid semantics)
+// #import static under_a
+
+//# $f
+void over_b( struct b_t * p, int depth ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "over_b -> a\n" );
+    a(& p->a, depth);
+    printf( "over_b -> b\n" );
+    b( p, depth);
+}
Index: doc/proposals/modules-gen-hdr/cfa-cppp
===================================================================
--- doc/proposals/modules-gen-hdr/cfa-cppp	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/cfa-cppp	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,177 @@
+#! /usr/bin/python3
+
+import fileinput
+import sys
+import re
+import os
+from enum import Enum
+
+class Section(Enum):
+    PREAMBLE = 1
+    EXP_TYPE = 2
+    EXP_VALUE = 3
+    STATIC = 4
+    UNKNOWN = 5
+
+class ValueSubsection(Enum):
+    FUNCTION = 1
+    VARIABLE = 2
+    NA = 3
+
+outfile = sys.argv[1]
+outfile_local = os.path.basename(outfile)
+parts = re.match(r"(?P<module>.*)\.(?P<mode>[^\.]*)\.[hc]$", outfile_local)
+module = parts.group('module')
+outtype = parts.group('mode')
+
+srcfile = os.path.join(os.path.dirname(outfile), module) + ".src.c"
+circImpVar = "__{mod}_{ty}_IMPORTING__".format(mod=module.upper(), ty=outtype.upper())
+
+sys.stdout = open(outfile, 'w')
+
+# data about the current //#-delimited chunk of file
+section = Section.PREAMBLE
+valueSubsection = ValueSubsection.NA
+lines = []
+
+def declOnly():
+    if valueSubsection == ValueSubsection.VARIABLE:
+        eqpos = lines[0].find('=')
+        lines[0] = lines[0][0:eqpos]
+        print( 'extern', lines[0], ';' )
+    else:
+        if lines[0].endswith("{"):
+            lines[0] = lines[0][0:len(lines[0])-2].rstrip()
+        print( lines[0], ';' )
+
+def fulldump():
+    for line in lines:
+        print(line)
+
+def flush():
+    global lines
+    # print("\t// flush", outtype, section)
+
+    if (section == Section.PREAMBLE):
+        postpreamble()
+    elif (len(lines) == 0):
+        return
+    elif (outtype == 'tdcl') & (section == Section.EXP_TYPE):
+        declOnly()
+    elif (outtype == 'defn') & (section == Section.EXP_TYPE):
+        fulldump()
+    elif (outtype == 'defn') & (section == Section.EXP_VALUE):
+        declOnly()
+    elif (outtype == 'impl') & (section == Section.EXP_VALUE):
+        fulldump()
+    elif (outtype == 'impl') & (section == Section.STATIC):
+        fulldump()
+    else:
+        for line in lines:
+            pass #print("//", line)
+
+    lines = []
+
+class ImportStyle(Enum):
+    NO_EXPORT = 1
+    EXPORT_INCOMPLETE = 2
+    EXPORT_COMPLETE = 3
+
+def emitInclude(imodule, iftype):
+    print('#include "{mod}.{typ}.h"'.format(mod=imodule, typ=iftype))
+
+def import_(cmd):
+    if section == Section.PREAMBLE:
+        if cmd.startswith("auto"):
+            cmd = cmd.replace("auto","").lstrip()
+            if cmd.startswith("&"):
+                cmd = cmd.replace("&","").lstrip()
+                style = ImportStyle.EXPORT_INCOMPLETE
+            else:
+                style = ImportStyle.EXPORT_COMPLETE
+        elif cmd.startswith("static"):
+            cmd = cmd.replace("static","").lstrip()
+            style = ImportStyle.NO_EXPORT
+        else:
+            print("#error import not understood:", cmd)            
+            style = ImportStyle.NO_EXPORT
+        imodule = cmd
+        if( style != ImportStyle.EXPORT_COMPLETE) & (outtype == "impl"):
+            emitInclude(imodule, "defn")
+        if (style == ImportStyle.EXPORT_COMPLETE) & (outtype == "defn"):
+            emitInclude(imodule, "defn")
+        if (style != ImportStyle.NO_EXPORT) & (outtype == "tdcl"):
+            emitInclude(imodule, outtype)
+    else:
+        print("#error illegal place for: import ", cmd)
+
+def beginunit():
+    print("//", outfile_local)
+    if (outtype == "tdcl"):
+        print("#pragma once")
+    elif outtype == "defn":
+        print("#ifdef", circImpVar)
+        print("#error Illegal circularity detected")
+        print("#else")
+        print("#define", circImpVar)
+    if outtype == "defn":
+        emitInclude(module, "tdcl")
+    elif outtype == "impl":
+        emitInclude(module, "defn")
+
+def postpreamble():
+    if outtype == "defn":
+        print("#undef", circImpVar)
+        print("#pragma once")
+
+
+
+def endunit():
+    if outtype == "defn":
+        print("#endif // ", circImpVar)
+
+try:
+    with open(srcfile, "r") as file:
+        beginunit()
+        for line in file:
+            line = line.rstrip()
+            if ( line.startswith("#import") ):
+                line = line.replace("#import", "").lstrip()
+                import_(line)
+            elif ( line.startswith("//#") ):
+                flush()
+                line = line.replace("//#", "").lstrip()
+                if line[0] == '@':
+                    section = Section.EXP_TYPE
+                    valueSubsection = ValueSubsection.NA
+                elif line[0] == '$':
+                    section = Section.EXP_VALUE
+                    valueSubsection = ValueSubsection.NA
+                    # print("\t// object decl:{name}, with deps:{decldeps}".format(
+                    #     name=name, decldeps=decldeps))
+                    line = line[1:]
+                    if line[0] == 'f':
+                        valueSubsection = ValueSubsection.FUNCTION
+                    elif line[0] == 'v':
+                        valueSubsection = ValueSubsection.VARIABLE
+                    else:
+                        print("#error $-subdirective not understood: ", line)
+                        valueSubsection = ValueSubsection.NA
+                elif line[0] == '-':
+                    section = Section.STATIC
+                    valueSubsection = ValueSubsection.NA
+                else:
+                    print("#error directive not understood:", line)
+                    section = Section.UNKNOWN
+                    valueSubsection = ValueSubsection.NA
+                line = line[1:]
+            else:
+                line = line.split("//")[0].rstrip()
+                if (line):
+                    lines.append(line)
+        flush()
+        endunit()
+except FileNotFoundError:
+    print("Error: The file '" + srcfile + "' was not found.")
+
+
Index: doc/proposals/modules-gen-hdr/coop/chicken.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/coop/chicken.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/coop/chicken.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,27 @@
+#import auto & egg
+
+
+//# @
+struct chicken {
+  struct egg * hatchedFrom;
+};
+
+//# $f
+void ctor_chicken( struct chicken * this, struct egg * hatchedFrom ) { // probably autogen
+  this->hatchedFrom = hatchedFrom; // ctor_pointer$
+}
+
+//# $f
+void live( struct chicken * this ) {
+        int printf( const char *, ... );  // scaffold
+        void exit( int );
+
+  // scaffold
+  static int calls = 0;
+  if ((calls += 1) > 10) exit(0);
+
+  printf( "chicken %p hatched from egg %p\n", this, this->hatchedFrom );
+  struct egg laid; // not a pointer
+  ctor_egg( & laid, this );
+  hatch( & laid );
+}
Index: doc/proposals/modules-gen-hdr/coop/egg.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/coop/egg.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/coop/egg.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,18 @@
+#import auto chicken
+
+//# @
+struct egg {
+  struct chicken hatchling;  // not a pointer
+  struct chicken * layer;
+};
+
+//# $f
+void ctor_egg( struct egg * this, struct chicken * layer ) { // handwritten
+  ctor_chicken( & this->hatchling, this );
+  this->layer = layer; // ctor_pointer
+}
+
+//# $f
+void hatch( struct egg * this ) {
+  live( & this->hatchling );
+}
Index: doc/proposals/modules-gen-hdr/coop/main.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/coop/main.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/coop/main.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,8 @@
+#import static egg
+
+//# $f
+int main() {
+  struct egg e;
+  ctor_egg( & e, 0 );
+  hatch( & e );  
+}
Index: doc/proposals/modules-gen-hdr/err-vicious-typeof/a.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious-typeof/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious-typeof/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,14 @@
+#import auto vocab
+#import auto b
+
+//# $f
+struct x bar( void ) {
+    struct x ret = {};
+    return ret;
+}
+
+//# $f
+typeof( foo() ) foo2( void ) {
+    struct x ret = {};
+    return ret;
+}
Index: doc/proposals/modules-gen-hdr/err-vicious-typeof/b.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious-typeof/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious-typeof/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,18 @@
+#import auto vocab
+#import auto a
+
+//# $f
+struct x foo( void ) {
+    struct x ret = {};
+    return ret;
+}
+
+//# $f
+typeof( bar() ) bar2( void ) {
+    struct x ret = {};
+    return ret;
+}
+
+//# $f
+int main () {    
+}
Index: doc/proposals/modules-gen-hdr/err-vicious-typeof/vocab.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious-typeof/vocab.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious-typeof/vocab.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,4 @@
+//# @
+struct x {
+    int i;
+};
Index: doc/proposals/modules-gen-hdr/err-vicious/cu1.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/cu1.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/cu1.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,14 @@
+#import auto cu2
+
+//# @
+struct A {
+    int val;
+};
+
+//# @
+struct B {
+    struct X x;
+};
+
+//# -
+static struct Y y __attribute__((unused));
Index: doc/proposals/modules-gen-hdr/err-vicious/cu2.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/cu2.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/cu2.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,14 @@
+#import auto cu1
+
+//# @
+struct X {
+    double val;
+};
+
+//# @
+struct Y {
+    struct A a;
+};
+
+//# -
+static struct B b __attribute__((unused));
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.a.h
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.a.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.a.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,5 @@
+#pragma once
+
+struct A {
+    int val;
+};
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.b.h
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.b.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.b.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "cu2.x.h"
+
+struct B {
+    struct X x;
+};
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu1.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,9 @@
+#include "cu1.a.h" // unnecessary (demo not built enough to need self imports)
+#include "cu1.b.h"
+
+#include "cu2.y.h"
+
+static struct Y y __attribute__((unused));
+
+int main() {    
+}
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,6 @@
+#include "cu2.x.h" // unnecessary (demo not built enough to need self imports)
+#include "cu2.y.h"
+
+#include "cu1.b.h"
+
+static struct B b __attribute__((unused));
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.x.h
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.x.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.x.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,5 @@
+#pragma once
+
+struct X {
+    double val;
+};
Index: doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.y.h
===================================================================
--- doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.y.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/err-vicious/recourse-classic/cu2.y.h	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "cu1.a.h"
+
+struct Y {
+    struct A a;
+};
Index: doc/proposals/modules-gen-hdr/hello/a.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/hello/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/hello/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,17 @@
+#import static helper
+
+//# @
+struct a {
+    int x;
+};
+
+//# $v
+struct a glb_a = { 10 };
+
+//# $f
+void f_a( struct a p ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "f_a( a{ %d } ), glb_a == { %d }\n", p.x, glb_a.x );
+    help();
+    printf( "f_a end\n" );
+}
Index: doc/proposals/modules-gen-hdr/hello/b.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/hello/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/hello/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,28 @@
+#import auto a
+
+//# @
+struct b {
+    struct a y;
+};
+
+//# $v
+struct a glb_ba = { 20 };
+
+//# $v
+struct b glb_bb = { { 30 } };
+
+//# $f
+void f_b( struct b p ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "f_b( b{ { %d } } )\n", p.y.x );
+    printf( "\tglb_a == { %d }\n", glb_a.x);
+    printf( "\tglb_ba == { %d }\n", glb_ba.x);
+    printf( "\tglb_bb == { { %d } }\n", glb_bb.y.x );
+    glb_a.x += 1;
+    p.y.x += 1;
+    f_a( p.y );
+  #ifdef ERR1
+    help();  // reject => a's `#import static helper` not visible here
+  #endif
+    printf( "f_b end\n" );
+}
Index: doc/proposals/modules-gen-hdr/hello/c.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/hello/c.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/hello/c.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,48 @@
+#import auto b
+#import static helper
+
+//# @
+struct c {
+    struct b z;
+    struct a q;
+};
+
+//# $v
+struct a glb_ca = { 40 };
+
+//# $v
+struct b glb_cb = { { 50 } };
+
+//# $v
+struct c glb_cc = { { { 60 } }, { 70 } };
+
+//# $f
+void f_c( struct c p ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "f_c( c{ b{ a{ %d } }, a{ %d } } )\n", p.z.y.x, p.q.x );
+    printf( "\tglb_a == a{ %d }\n", glb_a.x);
+    printf( "\tglb_ba == a{ %d }\n", glb_ba.x);
+    printf( "\tglb_bb == b{ a{ %d } }\n", glb_bb.y.x );
+    printf( "\tglb_ca == a{ %d }\n", glb_ca.x);
+    printf( "\tglb_cb == b{ a{ %d } }\n", glb_cb.y.x );
+    printf( "\tglb_cc == c{ b{ a{ %d } }, a{ %d } }\n", glb_cc.z.y.x, glb_cc.q.x );
+    glb_a.x += 1;
+    glb_ba.x += 1;
+    glb_bb.y.x += 1;
+    p.z.y.x += 1;
+    p.q.x += 1;
+    f_b( p.z );
+    f_a( p.q );
+    help();  // accept => a's `#import static helper` independent from here
+    printf( "f_c end\n" );
+}
+
+//# $f
+int main() {
+    struct a la = { 500 };
+    struct b lb = { { 600 } };
+    struct c lc = { { { 700 } }, { 800 } };
+    f_a(la);
+    f_b(lb);
+    f_c(lc);
+}
Index: doc/proposals/modules-gen-hdr/hello/helper.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/hello/helper.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/hello/helper.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,5 @@
+//# $f
+void help( void ) {
+        int printf( const char *, ... );  // scaffold
+    printf( "Help!\n" );
+}
Index: doc/proposals/modules-gen-hdr/typeof/a.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/typeof/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/typeof/a.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,7 @@
+#import auto vocab
+#import auto b
+
+//# @
+struct y {
+    typeof( foo() ) f;
+};
Index: doc/proposals/modules-gen-hdr/typeof/b.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/typeof/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/typeof/b.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,18 @@
+#import auto vocab
+#import auto & a
+
+//# $f
+struct x foo( void ) {
+    struct x ret = {};
+    return ret;
+}
+
+//# $f
+struct y bar( void ) {
+    struct y ret = {};
+    return ret;
+}
+
+//# $f
+int main () {    
+}
Index: doc/proposals/modules-gen-hdr/typeof/vocab.src.c
===================================================================
--- doc/proposals/modules-gen-hdr/typeof/vocab.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
+++ doc/proposals/modules-gen-hdr/typeof/vocab.src.c	(revision b28ce93ef6648a426d1fb594f74b51bfeda9976c)
@@ -0,0 +1,4 @@
+//# @
+struct x {
+    int i;
+};
