How can I use class and wasm?

Jack jckj33 at gmail.com
Thu Oct 15 22:02:11 UTC 2020


can I make it work? the code (see below) result in link error:

>lld: error: wasm.o: undefined symbol: _D4wasm1C7__ClassZ
>lld: error: wasm.o: undefined symbol: _d_allocclass
>Error: linking with LLD failed

command line:

>ldc2 --d-debug -mtriple=wasm32-unknown-unknown-wasm -betterC 
>wasm.d

ldc version:
> 1.24.0-beta1 (DMD v2.094.0, LLVM 11.0.0)

code:

>extern(C): // disable D mangling
>// seems to be the required entry point
>void _start() {}
>
>extern(C)
>int g()
>{
>    auto c = new C();
>    return c.f();
>}
>
>extern(C++)
>{
>    class C
>    {
>        int f() { return 42; }
>    }
>}


More information about the Digitalmars-d-learn mailing list