I have a legacy project which has a singleton class like this:
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton inst;
return inst;
}
void foo();
};
The project uses a DLL which needs to use the same class (part of the source is shared between the hosting application and the DLL, so the DLL has access to Singleton
). However, Instance
(naturally) returns a different instance for DLL, and a different one for the hosting application. This obviously causes problems.
Is there a way to use the same instance between the DLL and the hosting process? (let's assume that binary compatibility is not an issue.)