Calling D from C, C++, Python…
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 12 09:20:07 PDT 2015
On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg
wrote:
> Well, if your D function doesn't use anything of the runtime I
> guess it's not necessary.
Right. If you don't call into the threading system in the
druntime, you should be ok. Keep in mind though that the GC uses
the threads.... and the new expression, array literals, array
append, and others use the GC.
Runtime.initialize is also what calls static and module
constructors... and might have responsibility for fixing up
dynamic casting of class objects in a shared lib too, I'm not
sure about that.
But if you avoid the bulk of the runtime functions, indeed you
can get away without initializing it. Just that null thread
handle is likely to cause segfaults in places where you might not
expect if you don't.
It is best to initialize it. Lots of C libraries need an init an
teardown call, so surely the Python interop provides some
solution for it. idk what it would be though.
More information about the Digitalmars-d-learn
mailing list