Hi all,
I have a list of variable in the anonymous namespace in one .cpp and a class with only static function to get them in the .h.
Two static function inside the same class : Init() and Shutdown() used to call class init function when needed on these variables and order of destroy.
All works fine in static lib but when I compile in shared lib I got lot of warnings like that :
warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
And a crash on the call of the Init() function.
How solve this problem ?
Thanks for the help
Shared libraries cannot have static data because there is no way to actually set up the static data when the library is used, or a way to shut it down when the library is no longer in use. (This also can cause a problem because two programs using the same shared library could then access data cross-process, when isn't usually allowed)
This is yet another reason to not use globals (tm). At the very least you should store them in some sort of allocated memory structure that is then passed to the functions that need access to them.
Disregard - I didn't read the error documentation like a noob. (Global state is still bad though)