How can I use class and wasm?
Adam D. Ruppe
destructionator at gmail.com
Fri Oct 16 03:42:22 UTC 2020
On Friday, 16 October 2020 at 03:04:25 UTC, Jack wrote:
> How can I allocate memory for this class?
It is possible but not easy without druntime.
If you are using -betterC, you can use extern(C++) classes with
extern(D) members. The compiler will let you declare that. But
then you need to allocate it. `__traits(classInstanceSize,
Whatever)` will tell you the size to malloc, but you also need to
copy an initializer over before you call the constructor.
I have a technique here that works on dmd...
but ldc is more strict about the type definition and I don't know
the magic it expects there... like it should be doable but idk
how so this might not be of much use.
Personally, I prefer to just not use betterC and make my own mini
But that's also not easy, lots of unfinished cases in my thing,
but I did manage to make it work... for my specific case.
More information about the Digitalmars-d-learn