globals are bad I know, but even statics local to a function appear to be bad.
I noticed that on linux, globals and statics inside a shared object (dynamic library) are initialised the first time you use dlopen. But when you dlclose, and then dlopen again, it doesn't initialise globals or statics the second time.
I used RTLD_NOLOAD with dlopen to test if dlclose actually removed the libary, and it said it has, so this isn't a reference count issue.
This isn't the same as windows: http://msdn.microsoft.com/en-us/library/988ye33t.aspx Which I've tested and does appear to re-initialise statics.
Is this true, or am I just messing something else up?
If this is true, wouldn't this make any kind of static variable dangerous/useless?
man 3 dlopen:flag RTLD_NODELETE : [...] the library's static variables are not reinitialized if the library is reloaded with dlopen() at a later time. [...]. Since this flag is not mandatory as contrary toRTLD_LAZYorRTLD_NOWflags, doesn't this imply that by default static variables should be reinitialized ?