I am working on an application written in Visual Studio 6 (I know FML) that calls functions in a DLL with LoadLibraryand GetProcAddress. New code cannot compile in VC6 and a newer compiler is needed. The DLL has several functions that build a C ++ object, and then the VC6 program uses the object through an abstract class.
This works fine, but it causes problems when functions obtained with GetProcAddressexception exceptions, even if the exceptions get into the DLL. I noticed that this does not happen when class abstract methods throw an exception. In this case, everything works fine.
What am I doing wrong here? How can I get VC6 to generate code to handle exceptions correctly?
Change . Here is an example of a function that causes a program to crash:
extern "C" __declspec(dllexport) Box* getBox(const char* addr)
{
try {
return createBox(addr);
} catch (std::exception& ex) {
LOG_ERROR("Open failed: " << ex.what());
return 0;
} catch (...) {
LOG_ERROR("Error while opening.");
return 0;
}
}
Brian source
share