On Thu, Apr 12, 2012 at 1:23 PM, Bradley Lowekamp <[email protected]> wrote: > static bool MetaImageIOFactoryHasBeenRegistered; > > I don't under stand how MetaImageIOFactoryHasBeenRegistered gets initialized > before usage. And then is the static initialization fiasco [1] an issue?
When the type of a global is a plain-old-data (POD) type the compiler default-initializes it to zero (false for bool). We purposely take advantage of default initialization because the code that modifies/tests the variable may be invoked during static initalization of *another* translation unit. If we had an explicit initializer then it would overwrite whatever work had been done so far (from other translation units) when the translation unit defining the global is explicitly initialized. This approach is the same as some vendors' standard libraries use to initialize singletons like "cout" and "cerr" AFAIK. -Brad K _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Kitware offers ITK Training Courses, for more information visit: http://kitware.com/products/protraining.php Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ Follow this link to subscribe/unsubscribe: http://www.itk.org/mailman/listinfo/insight-developers
