Introduce C entry point support for plugin setup for better static build support

This commit is contained in:
Robert Osfield 2007-05-25 15:27:06 +00:00
parent 1676ae839f
commit 8a1ac890f3
2 changed files with 25 additions and 2 deletions

View File

@ -565,6 +565,29 @@ class RegisterReaderWriterProxy
osg::ref_ptr<T> _rw; osg::ref_ptr<T> _rw;
}; };
extern "C"
{
typedef void (* CPluginFunction) (void);
}
class PluginFunctionProxy
{
public:
PluginFunctionProxy(CPluginFunction function)
{
(function)();
}
};
#define USE_OSGPLUGIN(ext) \
extern "C" void osgdb_##ext(void); \
static osgDB::PluginFunctionProxy proxy_##ext(osgdb_##ext);
#define REGISTER_OSGPLUGIN(ext, classname) \
extern "C" void osgdb_##ext(void) {} \
static RegisterReaderWriterProxy<classname> g_proxy_##classname;
} }
#endif #endif

View File

@ -10,7 +10,7 @@
using namespace osg; using namespace osg;
using namespace osgDB; using namespace osgDB;
class IVEReaderWriter : public ReaderWriter class ReaderWriterIVE : public ReaderWriter
{ {
public: public:
virtual const char* className() const { return "IVE Reader/Writer"; } virtual const char* className() const { return "IVE Reader/Writer"; }
@ -186,4 +186,4 @@ class IVEReaderWriter : public ReaderWriter
// now register with Registry to instantiate the above // now register with Registry to instantiate the above
// reader/writer. // reader/writer.
RegisterReaderWriterProxy<IVEReaderWriter> g_IVEReaderWriterProxy; REGISTER_OSGPLUGIN(ive, ReaderWriterIVE)