diff Plugins/Engine/PluginsManager.cpp @ 893:f57802f8b4dc plugins

plugins for windows
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jun 2014 16:14:56 +0200
parents d2a393061eb6
children 690aeb4cb899
line wrap: on
line diff
--- a/Plugins/Engine/PluginsManager.cpp	Mon Jun 16 15:41:13 2014 +0200
+++ b/Plugins/Engine/PluginsManager.cpp	Mon Jun 16 16:14:56 2014 +0200
@@ -53,6 +53,9 @@
   {
     typedef int32_t (*Initialize) (const OrthancPluginContext*);
 
+#if defined(_WIN32)
+    Initialize initialize = (Initialize) plugin.GetFunction("OrthancPluginInitialize");
+#else
     /**
      * gcc would complain about "ISO C++ forbids casting between
      * pointer-to-function and pointer-to-object" without the trick
@@ -64,8 +67,9 @@
 
     Initialize initialize;
     *(void **) (&initialize) = plugin.GetFunction("OrthancPluginInitialize");
+#endif
+
     assert(initialize != NULL);
-
     int32_t error = initialize(&context);
 
     if (error != 0)
@@ -81,10 +85,14 @@
   {
     typedef void (*Finalize) ();
 
+#if defined(_WIN32)
+    Finalize finalize = (Finalize) plugin.GetFunction("OrthancPluginFinalize");
+#else
     Finalize finalize;
     *(void **) (&finalize) = plugin.GetFunction("OrthancPluginFinalize");
+#endif
+
     assert(finalize != NULL);
-
     finalize();
   }
 
@@ -93,10 +101,14 @@
   {
     typedef const char* (*GetName) ();
 
+#if defined(_WIN32)
+    GetName getName = (GetName) plugin.GetFunction("OrthancPluginGetName");
+#else
     GetName getName;
     *(void **) (&getName) = plugin.GetFunction("OrthancPluginGetName");
+#endif
+
     assert(getName != NULL);
-
     return getName();
   }
 
@@ -105,10 +117,14 @@
   {
     typedef const char* (*GetVersion) ();
 
+#if defined(_WIN32)
+    GetVersion getVersion = (GetVersion) plugin.GetFunction("OrthancPluginGetVersion");
+#else
     GetVersion getVersion;
     *(void **) (&getVersion) = plugin.GetFunction("OrthancPluginGetVersion");
+#endif
+
     assert(getVersion != NULL);
-
     return getVersion();
   }
 
@@ -150,6 +166,9 @@
     {
       if (it->second != NULL)
       {
+        LOG(WARNING) << "Unregistering plugin '" << CallGetName(*it->second)
+                     << "' (version " << CallGetVersion(*it->second) << ")";
+
         CallFinalize(*(it->second));
         delete it->second;
       }