is below code correct in regard to the static local variable? Will it be properly initialized? I heard that initialization may fail in case of DLLs!
#include <windows.h>
class SomeClass
{
public:
int anything;
};
BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID)
{
static SomeClass *someClass = nullptr;
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
if (!someClass) {
someClass = new SomeClass();
}
break;
case DLL_PROCESS_DETACH:
if (someClass) {
delete someClass;
someClass = nullptr;
}
break;
}
return TRUE;
}