mbebenita / LLJS

LLJS: Low-Level JavaScript
http://lljs.org
Other
1.18k stars 89 forks source link

allocating an array of pointers to custom struct types #17

Open jlongster opened 12 years ago

jlongster commented 12 years ago

If I try to compile this code:

struct Foo {
    int bar;
    int baz;
}

let Foo** arr = new Foo*[100];

I get this error:

main2.ljs:7:7: error: incompatible types: assigningdyn' to Foo**'

What am I doing wrong?

rinon commented 12 years ago

I believe you need to do:

typedef Foo* FooPointer;
let FooPointer* arr = new FooPointer[100];
jlongster commented 12 years ago

Yep, that worked. Is this a real bug? Since a lot of the syntax seems C/C++ inspired, seems like this could be a nice addition.

mbebenita commented 12 years ago

Yah, it seems to be broken. I'll take a look at it.