Re: unloading plugins (i.e. shared objects) nearly impossible!
davidbaraff@gmail.com wrote:
That would require that the API's in the main program all support this.
For example, my main program has a centralized dictionary:
void SetValueInDictionary(string key, boost::any value) {
...
}
I cannot call this safely from my plugin. Effectively, the number of
things I can do safely from my plugin just got a lot, lot smaller.
It's fine to say "track every pointer you ever give out from your
plugin", but just how the heck is the average programmer supposed to
know this?
Take the boost::any as a concrete example. The whole point of this
class is to make passing heterogenous data around by value simple and
tractable. Should programmers need to understand that, because the
implementation uses intenal polymorphic objects, you're screwed?
As has been pointed out, you can't use objects allocated by the plug-in
in this manner. Have you considered restructuring the interface to the
plugin such that you allocate the object in the main program and pass
it to the plug-in to be filled? That can often work because the code
for the object is then in the main program rather than in the plugin.
joe
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]