On Thursday, 16 June 2022 at 16:37:34 UTC, Ali Çehreli wrote:
Agreed but that excludes using the D runtime in 'static this'
(and shared) blocks, right?
It is runtime.initialize that calls those `static this` blocks.
If my explicit call to Initialize is in a 'shared static this'
This is backward - the explicit call to Initalize is in the exe.
It'd look like:
// this code is in the exe! pretend it is C++ or whatever
HANDLE lib = LoadLibrary("my_d_lib.dll");
if(lib !is null) {
auto fn = cast(typeof(init_func))
GetProcAddress("Initialize");
if(fn !is null) {
fn(); // this now calls runtime.initialize which calls
the static this blocks etc
// you're now good to call any D functions
}
}