pervognsen / bitwise

Bitwise is an educational project where we create the software/hardware stack for a computer from scratch.
Other
5.12k stars 212 forks source link

TypeInfo generated for undeclared types #52

Closed mcavanagh closed 6 years ago

mcavanagh commented 6 years ago

Steps to reproduce:

  1. Create a package libfoo with one file with the following contents:
    
    struct Foo {
    x, y: int;
    }

func bar() { foo: Foo; foo_p := &foo; foo_pp := &foo_p; // This triggers the type info generation for 'libfoo_Foo' }



2. Create a second package with a `main` method and `import libfoo {...}`

Ion compilation works, but the generated C will error on compilation with `error C2065: 'libfoo_Foo': undeclared identifier`.

You'll get a line similar to:
`[190] = &(TypeInfo){TYPE_PTR, .size = sizeof(void *), .align = alignof(void *), .base = TYPEID(53, TYPE_PTR, libfoo_Foo *)},`

If the `struct Foo` isn't directly used in the `main` package, the C struct def for `Foo` will never be generated.
pervognsen commented 6 years ago

Thanks, I'm taking a look.

pervognsen commented 6 years ago

Should be fixed.