www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - DMC not exporting handles from DLL

↑ ↓ ← Boroto <Boroto_member pathlink.com> writes:
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

Building Client / Compiler output:
dmc Client.cpp Nothing.lib

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?
May 21 2004
↑ ↓ → "Walter" <newshound digitalmars.com> writes:
The fix for this will go out in the next update. Thanks, -Walter
May 22 2004