From: Eric S. <sun...@su...> - 2004-03-21 03:25:40
|
On Sat, 20 Mar 2004 23:26:50 +0100, Norman Kramer wrote: > Am Saturday 20 March 2004 21:14 schrieb res: > > IIRC the static var macros were introduced because on certain platforms > > destructors for global vars weren't invoked when a dynamic lib was > > unloaded. What platforms are affected by this problem? Could there be a > > chance it isn't an issue any more at all? > this was an issue with at least gcc 2.95.2 and 2.95.3 (although i read > posts on the gcc ml that claimed it was solved, it wasn't - back then) Actually, the real issue was not static variable cleanup, but rather global variable initialization. The problem is that there are platforms which do not guarantee that initialization code will be run when the initialization code is for global variables (including class variables), if those variables reside in dynamically loaded plugin modules. In other words, there is no guarantee that the following example variables will be initialized properly (or at all) if they are in a plugin module: float foo = sqrt(5.4); MyObject bar; // Constructor might not be invoked. Some platforms will run this initialization code when it resides in a plugin module at the time that the plugin module is loaded. Other platforms will not. Some platforms (such as Apple) have even had release notes saying "such initialization code may or may not be run", as if it is random. To work around this problem, we delay initialization of these variables until their values are queried (or set) the very first time, in which case we can insure that they are properly constructed. The "cleanup" issue is just a side-effect (a conclusion) of the above fix. -- ES |