www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dll error

reply "sdv" <sdvcn 126.com> writes:
a.d

----------------------------
import core.runtime;
import core.sys.windows.windows;
import core.sys.windows.dll;

//import mach3plugins;

__gshared HINSTANCE g_hInst;
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID 
pvReserved)
{
    switch (ulReason) {
        case DLL_PROCESS_ATTACH:
            g_hInst = hInstance;
            dll_process_attach( hInstance, true );
            break;
        case DLL_PROCESS_DETACH:
            dll_process_detach( hInstance, true );
            break;
        case DLL_THREAD_ATTACH:
            dll_thread_attach( true, true );
            break;
        case DLL_THREAD_DETACH:
            dll_thread_detach( true, true );
            break;
        default:

    }
    return true;
}


//D, C, C++, Pascal, Windows, System

extern (C) export void MyVer0()
{
}

extern (C) export void MyVer1()
{
}

extern (C) export void MyVer2()
{
}
----------------------------------
out:
_MyVer0
MyVer1
MyVer2
Dec 01 2011
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 01.12.2011 18:01, sdv wrote:
 a.d

 ----------------------------
 import core.runtime;
 import core.sys.windows.windows;
 import core.sys.windows.dll;

 //import mach3plugins;

 __gshared HINSTANCE g_hInst;
 extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID
 pvReserved)
 {
      switch (ulReason) {
          case DLL_PROCESS_ATTACH:
              g_hInst = hInstance;
              dll_process_attach( hInstance, true );
              break;
          case DLL_PROCESS_DETACH:
              dll_process_detach( hInstance, true );
              break;
          case DLL_THREAD_ATTACH:
              dll_thread_attach( true, true );
              break;
          case DLL_THREAD_DETACH:
              dll_thread_detach( true, true );
              break;
          default:

      }
      return true;
 }


 //D, C, C++, Pascal, Windows, System

 extern (C) export void MyVer0()
 {
 }

 extern (C) export void MyVer1()
 {
 }

 extern (C) export void MyVer2()
 {
 }
 ----------------------------------
 out:
 _MyVer0
 MyVer1
 MyVer2

You have run into a bug in the linker: http://d.puremagic.com/issues/show_bug.cgi?id=3956 A workaround is to use a "noop" def-file: EXETYPE NT LIBRARY "a.dll" CODE PRELOAD DISCARDABLE DATA PRELOAD MULTIPLE EXPORTS _MyVer0 = _MyVer0 PRIVATE _MyVer1 = _MyVer1 PRIVATE _MyVer2 = _MyVer2 PRIVATE
Dec 01 2011