<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>As you said on windows this a problem, because these ImageIO libraries are still static in a shared build. So there may be multiple of the HasBeenRegistered for each dll. While for some application it's easy to control where the registration occurs for larger its much more complex.</div><div><br></div><div>Perhaps specifically consider SimpleITK build with ITK with both shared libraries. In SimpleITK only the registration occurs just in the IO sub-library. However, if the applications wants to use both ITK and SimpleITK, its very likely that the registration will happen again. If I understand what in means to link the static libraries to a dll, this may reck havoc on third party libraries singleton-type data as there may be multiple versions in each dll.</div><div><br></div><div>Slicer is one example of the above situation with ITK and SimpleITK. Additionally, it has extensions where a single file gets compiled into both a dynamic library and an executable. The current define ITK_NO_IO_FACTORY_REGISTER_MANAGER before "using ITK", does not provide the needed flexibility for such situations.</div><div><br></div><div>Does it sound easier to address these issues for each application or could the ImageIO be made shared on windows?</div><div><br></div><div>The reason I am thinking about this issue so much is the quarter million of valgrind errors I got from mixing static ITK libraries with shared simpleITK libraries[1] mostly appear related to HDF5 and GDCM static initialization and destruction. And have been pondering what this means for Windows libraries.</div><div><br></div><div><a href="http://open.cdash.org/viewDynamicAnalysisFile.php?id=2736128">http://open.cdash.org/viewDynamicAnalysisFile.php?id=2736128</a></div><div><br></div><div>Brad</div><div><br><div><div>On Apr 12, 2012, at 1:51 PM, Brad King wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Thu, Apr 12, 2012 at 1:23 PM, Bradley Lowekamp<br><<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>> wrote:<br><blockquote type="cite">static bool MetaImageIOFactoryHasBeenRegistered;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I don't under stand how MetaImageIOFactoryHasBeenRegistered gets initialized<br></blockquote><blockquote type="cite">before usage. And then is the static initialization fiasco [1] an issue?<br></blockquote><br>When the type of a global is a plain-old-data (POD) type the compiler<br>default-initializes it to zero (false for bool). We purposely take<br>advantage of default initialization because the code that<br>modifies/tests the variable may be invoked during static initalization<br>of *another* translation unit. If we had an explicit initializer then<br>it would overwrite whatever work had been done so far (from other<br>translation units) when the translation unit defining the global is<br>explicitly initialized.<br><br>This approach is the same as some vendors' standard libraries use to<br>initialize singletons like "cout" and "cerr" AFAIK.<br><br>-Brad K<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>