Boost logo

Boost :

Subject: Re: [boost] Any interest in static plugins?
From: Jeremy Pack (rostovpack_at_[hidden])
Date: 2009-11-30 11:13:16


My team works on code that uses a lot of static initialization for global
variables. Based on this difficult experience, I would highly recommend
initializing the factories inside of functions called after main() has
started, rather than in static initializers. The amount of code to make this
work correctly across platforms is nontrivial. In fact, we require that a
certain initialization function be called as soon as main() has started,
just to clean up all of the messes left by doing static initialization of so
many things. I believe that this original design was a mistake - but we have
too much code to change it overnight.

I wouldn't call it "doomed to failure" - just difficult to get right, and
probably not worth the effort to get it right.

I wrote some code for the sandbox a while ago that does this:

http://boost-extension.redshoelace.com/docs/boost/extension/boost_extension/tutorials/tutorial02.html

It works for both static and dynamic linking, and for shared libraries that
are determined at run time (the shared libraries need to have been compiled
with the same compiler options). It also allows arbitrary constructor
signatures, inheritance across shared libraries, reflection and a few other
features.

I've been waiting to finalize the reflection functionality (it works, but I
don't like parts of the API) until C++0x is more finalized in the various
compilers.

Jeremy Pack


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk