[cfe-dev] Priority settings for static variables and __attribute__((destructor))
anton at korobeynikov.info
Sun Feb 17 05:38:25 PST 2013
> Well, this would be a weak point since Apple recommend
> __attribute__((destructor)) as a module finalizer.
And this is perfectly fine. As I said, 'constructor' and 'destructor'
attributes are recognized and work w/o any problems.
You cannot rely on priorities scattered across different modules.
> Does this mean that the module ctor/dtor are unable to safely use any
> existing static variables?
Static variables of which type? The example you mentioned seems to be
written in C. In C there are no constructors / destructors (in C++
sense), so you're fine here.
In C++ case you need to use init_priority attribute. And again, you
can rely on the order of constructor / destructor execution only
inside single module (on darwin).
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
More information about the cfe-dev