Chaos!!! In C++ language, the question on when a non-local static object is initialized is not specified in C++ standard specification.
So, if you abuse non-local static variables, it means that you find fault with yourself.
You can substitute Singleton pattern for non-local static variables, or adopt another way like following example.
StaticObjct& getStaticObject(){
static StaticObject staticObj;
return staticObj;
}
When meet a local static variable, C++ compilor initialize it at a time. Maybe you can use "inline" modifier. Don't forget the bad side of
"inline". It can duplicate variables more than one copy in your program; it just is recommand by a C++ compilor.
I had some misconstruction on C++, though I don't like it. I am aware that C++ like perl. They are all complex programming languages. So,
they can describe the complicated reality, they also perplex many people at the same time.
As a programmer, we should not run down C++ or other language else. Everything has good sides has bad sides at once! In my philosophy, everything
is chaos!