LLJS icon indicating copy to clipboard operation
LLJS copied to clipboard

allocating an array of pointers to custom struct types

Open jlongster opened this issue 12 years ago • 3 comments

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?

jlongster avatar Oct 29 '12 02:10 jlongster

I believe you need to do:

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

rinon avatar Oct 29 '12 02:10 rinon

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.

jlongster avatar Oct 29 '12 02:10 jlongster

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

mbebenita avatar Oct 29 '12 05:10 mbebenita