<div dir="ltr"><div class="gmail_extra">Well, this would be a weak point since Apple recommend __attribute__((destructor)) as a module finalizer.  </div><div class="gmail_extra"> </div><div class="gmail_extra">From: </div>
<div class="gmail_extra"> </div><div class="gmail_extra"><a href="https://developer.apple.com/library/mac/#documentation/macosx/Conceptual/BPFrameworks/Tasks/InitializingFrameworks.html#//apple_ref/doc/uid/20002259-BDEIDDJG">https://developer.apple.com/library/mac/#documentation/macosx/Conceptual/BPFrameworks/Tasks/InitializingFrameworks.html#//apple_ref/doc/uid/20002259-BDEIDDJG</a></div>
<div class="gmail_extra"> </div><div class="gmail_extra">"Module initializers are the preferred way to initialize a framework. A module initializer is a static function that takes no arguments and returns no value. It is declared using the <font face="Courier New">constructor </font>compiler attribute as shown in <span>Listing 1</span>. "</div>
<div class="gmail_extra"> </div><div class="gmail_extra">Does this mean that the module ctor/dtor are unable to safely use any existing static variables?</div><div class="gmail_extra"> </div><div class="gmail_extra">Thanks.</div>
<div class="gmail_extra"> </div><div class="gmail_extra">Huaxia</div><div class="gmail_extra"> </div><div class="gmail_extra"><br> </div><div class="gmail_quote">On 17 February 2013 20:01, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Hello<br>
<div class="im"><br>
> When dylib unloaded, the static variable Resource will be unloaded first<br>
> then clang will call shutdown() with a crash.   I tried GCC style<br>
> __attribute__((destructor(100))) to set the priority but it seems that clang<br>
> cannot recongnised this.<br>
</div>It does recognize this, but on darwin constructor / destructor<br>
priorities works only inside single module.<br>
<div class="im"><br>
> Is there anyway I can precisely constrol the order of static variables<br>
> deconstruction and attributed destructor functions in clang.  My environment<br>
> is Mac OS X 10.7.5, Xcode 4.6 with clang-425.0.24 x86_64-aple-darwin11.4.2<br>
</div>If I remember correctly, on darwin the order of ctors / dtors is<br>
induced by link order. Though, in general you cannot rely on this :)<br>
<span><font color="#888888"><br>
--<br>
With best regards, Anton Korobeynikov<br>
Faculty of Mathematics and Mechanics, Saint Petersburg State University<br>
</font></span></blockquote></div><div class="gmail_extra"><br></div></div>