__attribute__ ((destructor)) functions vs static global variables
__attribute__ ((destructor)) functions vs static global variables
- Subject: __attribute__ ((destructor)) functions vs static global variables
- From: Jesper Papmehl <email@hidden>
- Date: Thu, 4 Aug 2005 18:59:30 +0200
I have a function that is called by the runtime code when my loadable
bundle is unloaded. I have achieved this using __attribute__
((destructor)) (previously #pragma CALL_ON_UNLOAD).
I need to access static global data from within my "bundle
destructor". However, it seems this doesn't work. My guess is that
the runtime code is destructing static data before calling the
"bundle destructor". Is there any way to control this behavior?
The reason I need this: In our class library, we have a mechanism to
register functions that should be called when the current code module
"exits". For an app, that is when the app quits. For a loadable
bundle (and frameworks), that is when the bundle is unloaded. We
store the registered functions in a static global. We need access to
this global when the "bundle destructor" is called, so that we can
call the registered exit functions.
(When building with CodeWarrior, this isn't a problem, mainly because
you have to destroy statics yourself by calling __destroy_global_chain
(), and then you have control over exactly when it is done.)
Thanks in advance for any help!
/Jesper
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden