May 22, 2004 DMC not exporting handles from DLL | ||||
---|---|---|---|---|
| ||||
I'm using DMC 8.40 on Win98 SE. Windows handles (HWND, HINSTANCE, ...) not exported from DLL. Sample code is: // ------------------------------------------------ // Nothing.h // ------------------------------------------------ #include <windows.h> #ifdef CMPDLL #define EXPALL __declspec(dllexport) #define EXPVAR __declspec(dllexport) extern #else #define EXPALL __declspec(dllimport) #define EXPVAR __declspec(dllimport) extern #endif EXPVAR HWND NoExp; // Not exported with DMC EXPVAR int ExpOk; // Exported OK EXPALL int FunOk(long x); // Exported OK // ------------------------------------------------ // Nothing.cpp // ------------------------------------------------ #include "Nothing.h" BOOL WINAPI DllMain(HINSTANCE h,DWORD d, LPVOID p) {return TRUE;} EXPALL HWND NoExp = 0; EXPALL int ExpOk = 0; EXPALL int FunOk(long x) {NoExp=(HWND)x; return ++ExpOk;} // ------------------------------------------------ // Client.cpp // ------------------------------------------------ #include <stdio.h> #include "Nothing.h" int main() { printf("DMC DLL Test\n\n"); printf("FunOk(10) returns: %d\n", FunOk(10)); printf("NoExp = %ld ExpOk = %d\n", NoExp, ExpOk); printf("Altering NoExp to 20 and ExpOk to 2\n"); NoExp = (HWND)20; ExpOk = 2; printf("NoExp = %ld ExpOk = %d\n", NoExp, ExpOk); printf("FunOk(30) returns: %d\n", FunOk(30)); printf("NoExp = %ld ExpOk = %d\n", NoExp, ExpOk); printf("\n\nPress Enter to quit:"); getchar(); return (0); } // ------------------------------------------------ // DMC Command Line // ------------------------------------------------ Building DLL / Compiler output: >dmc -oNothing.dll -L/implib -WD -mn -DCMPDLL Nothing.cpp kernel32.lib user32.lib gdi32.lib link Nothing,Nothing.dll,,kernel32+user32+gdi32,Nothing/noi/implib; Building Client / Compiler output: >dmc Client.cpp Nothing.lib link Client,,,Nothing+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved Client.obj(Client) Error 42: Symbol Undefined ?NoExp@@3PAXA (void *NoExp) --- errorlevel 1 ---------------------------------------------------------------------------- Final comments: Compilation on bcc5.5 and mingw works fine. On DMC, "ExpOk" and "FunOk" exporteds ok, but "NoExp" handle is not exported. "NoExp" symbol not present in "Nothing.lib" import library. DLL Compilation gives no errors or warnings. Use of stlport or change .cpp extensions to .c do not solve the problem. Any sugestion, please? |
Copyright © 1999-2021 by the D Language Foundation