I have a private static member variable of a class foo (std::vector<double> values
). There is one object of foo capsulated in a dll (interface class and implementation class idiom). This is the header file 'foo.h':
class foo
{
public:
foo();
~foo();
private:
static std::vector<double> values;
};
And the definition file 'foo.cpp':
#include "foo.h"
std::vector<double> foo::values;
foo::foo()
{
values.resize(10UL);
}
foo::~foo()
{
for (auto& v :values)
{
v = 99.9;
}
}
In my main programm I load the dll with ::LoadLibrary(libraryName)
(Windows OS). When I perform ::FreeLibrary(libraryHandle)
and set a breakpoint in the destructor ~foo()
variables
seems already destroyed. Can somebody help me with the lifetime of static member variables in dlls? How can I prevent that static member variables are already destroyed when the destructor is called?
Thank you in advance.
Probably a similar question:
c++ Static variables in dynamic DLL lifetime. or why they dead?
I use Visual Studio 2013 with the Intel Parallel Studio XE 2016.
Aucun commentaire:
Enregistrer un commentaire