www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DLL with D (FreeLibrary problem)

reply Exec <dragon-x gmx.de> writes:
Hello everybody.
I'm trying to write a DLL in D. Everything is actually working fine, until I
reach FreeLibrary,
which terminates the test program (written in D) with code 0x1. DllMain is
called correctly,
and seems to run through. But I never reach the lines after the FreeLib call.

DLL: http://pastie.org/private/edvmql0g768blgx81nh14g
Def: http://pastie.org/private/lrmuzenou8clmjppqqj9gw
Program: http://pastie.org/private/2yvvjymgq5u50mtgyqjr0a
Output: http://pastie.org/private/kktyjs6hnbjohgwzwzqsjq

When I write the same program in C++, to test the DLL, I have a similar problem,
although the program doesn't crash. Nothing is printed, after FreeLib, but it's
waiting for the input at getch().

C++ Program: http://pastie.org/private/fehm1lgkxar87tantbgh0q

I'm still new to DLLs, or rather system programming in general,
and actually have near to no idea, what could be going wrong here.

Dec 30 2011
parent Exec <dragon-x gmx.de> writes:
It appears as if the following code in the detach case solves the problem:
 std.c.stdio._fcloseallp = null;
I'm not sure why though... why is the call such a problem, that even crashes the application, and doesn't it have any disadvantages, not to call it?
Dec 30 2011