Reference to D class instance with a C library

Leandro Motta Barros lmb at stackedboxes.org
Sat Jul 13 17:04:14 PDT 2013


> Also note that if the pointer in C land is the only reference to the
> class, the garbage collector will destroy the instance when it gets
> around to it.

Yup, I am aware of this. I mentioned that I can guarantee that my
object will outlive the C struct...

> There's a function GC.addRoot[1] in core.memory that can
> make the C struct keep the reference alive.

...but this may be useful anyway! Thanks :-)

LMB

PS: The community is a big plus for D. I hope to give something back
in the future :-)


More information about the Digitalmars-d-learn mailing list