|
Archives
D Programming
DD.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++.windows.32-bits - __declspec(dllexport) "doesn't work"
Hi, I'm sure I am being stupid here...
I'm compiling a DLL from a file test.c
=================================================
SOURCE FOR test.c
=================================================
#include <windows.h>
__declspec(dllexport) double WINAPI Test ( void ) {
return 4.0;
}
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
) {
}
=================================================
test.c is compiled with the command
dmc -mn -WD test.c kernel32.lib
This dll is called by another file with source test2.c
=================================================
SOURCE for test2.c
=================================================
#include <windows.h>
#include <stdio.h>
typedef double (WINAPI *doubleVoidProc)(void);
int main (int argc, char *argv[]) {
HMODULE h;
doubleVoidProc funcPtr;
printf("Loading DLL.. ");
h = LoadLibrary("test.dll");
if (!h) {
printf("Failed\n");
exit(1);
}
else
printf("OK\n");
funcPtr = (doubleVoidProc) GetProcAddress( h, "Test" );
if (!funcPtr) {
printf("Function not found\n");
exit(1);
}
printf("Function value %d\n", funcPtr());
FreeLibrary(h);
return 0;
}
=================================================
test2.c is compiled with the command
dmc test2.c
Despite the __declspec(dllexport) in test.c, the Test function does not get
exported unless I manually add the lines
EXPORT
Test
to the test.def file.
What am I doing wrong?
Cheers,
Simon
May 04 2006
Simon McGregor wrote: I'm not an DLL expert, but May 04 2006
|