[cfe-dev] Priority settings for static variables and __attribute__((destructor))

Huaxia huaxia.zhao at gmail.com
Sun Feb 17 03:37:58 PST 2013


Hello all:

I am helping to debug a Mach-o dylib program written by C++ and there are
some codes like this:

class Resource ; // global static variable

__attribute__((destructor))
void shutdown()
{
    Resource->Check();
}

When dylib unloaded, the static variable Resource will be unloaded
first then clang will call shutdown() with a crash.   I tried GCC style
__attribute__((destructor(100))) to set the priority but it seems that
clang cannot recongnised this.

Is there anyway I can precisely constrol the order of static variables
deconstruction and attributed destructor functions in clang.  My
environment is Mac OS X 10.7.5, Xcode 4.6 with clang-425.0.24
x86_64-aple-darwin11.4.2

Many thanks.

Huaxia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130217/6228d9c5/attachment.html>


More information about the cfe-dev mailing list