AHA!!!
I found the problem, the ordering of overloaded names (with different aegument lists) gets reversed on some compilers. Just watch this example program, when compiled in VC it gives the sequence 1 2 3 while in DevCPP it gives 3 2 1. So, what causes this and how can I solve it?
The DLL is ALWAYS compiled in VC++2003 (the client in both VC and DevCPP).
Dll:
Code:
#include <windows.h>
interface I
{
virtual INT __stdcall Get() = 0;
virtual INT __stdcall Get(INT X) = 0;
virtual INT __stdcall Get(INT X, INT Y) = 0;
};
class C : public I
{
public:
C() { }
~C() { }
virtual INT __stdcall Get() { return 1; };
virtual INT __stdcall Get(INT X) { return 2; };
virtual INT __stdcall Get(INT X, INT Y) { return 3; };
};
I* c = NULL;
extern "C" __declspec(dllexport) I* GetC()
{
return c;
}
BOOL WINAPI DllMain(HINSTANCE Dll, DWORD Reason, LPVOID Reserved)
{
switch(Reason)
{
case DLL_PROCESS_ATTACH:
{
c = new C();
break;
}
case DLL_PROCESS_DETACH:
{
delete c;
break;
}
}
return TRUE;
}
Client:
Code:
#include <windows.h>
#include <sstream>
interface I
{
virtual INT __stdcall Get() = 0;
virtual INT __stdcall Get(INT X) = 0;
virtual INT __stdcall Get(INT X, INT Y) = 0;
};
typedef I* (*GET_C)();
INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
{
I* c;
GET_C GetC;
std::stringstream Stream;
HINSTANCE Dll = LoadLibrary("DllMultiCompilerTest.dll");
if(Dll == NULL)
{
MessageBox(NULL, "No dll!", "Message", MB_OK);
return 0;
}
GetC = reinterpret_cast<GET_C>(GetProcAddress(Dll, "GetC"));
if(GetC == NULL)
{
FreeLibrary(Dll);
MessageBox(NULL, "No func!", "Message", MB_OK);
return 0;
}
c = GetC();
if(c == NULL)
{
FreeLibrary(Dll);
MessageBox(NULL, "No object!", "Message", MB_OK);
return 0;
}
Stream << "Get (should be 1 2 3):\n" << c->Get() << " " << c->Get(0) << " " << c->Get(0, 0);
MessageBox(NULL, Stream.str().c_str(), "Message", MB_OK);
FreeLibrary(Dll);
return 0;
}