summary refs log tree commit diff stats
path: root/lib/system/dyncalls.nim
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2015-03-05 14:44:54 -0600
committerSimon Hafner <hafnersimon@gmail.com>2015-03-05 14:44:54 -0600
commit70eaf92ff0493ed11c6e6c8887bca1b235371aff (patch)
tree530255b69df349728c76621e97bf40a11d63fe79 /lib/system/dyncalls.nim
parentf592240c545506448e2bea78a2fa3404c7f46e69 (diff)
parent8f43979cf6308c9d7e14a0d87c0faf227e1c4afe (diff)
downloadNim-70eaf92ff0493ed11c6e6c8887bca1b235371aff.tar.gz
Merge branch 'devel' into warning-for-result
Diffstat (limited to 'lib/system/dyncalls.nim')
-rw-r--r--lib/system/dyncalls.nim17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index e0d99cf88..44f7b67c3 100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -8,7 +8,7 @@
 #
 
 # This file implements the ability to call native procs from libraries.
-# It is not possible to do this in a platform independant way, unfortunately.
+# It is not possible to do this in a platform independent way, unfortunately.
 # However, the interface has been designed to take platform differences into
 # account and been ported to all major platforms.
 
@@ -80,15 +80,22 @@ elif defined(windows) or defined(dos):
   # Native Windows Implementation
   # =======================================================================
   #
-  type
-    THINSTANCE {.importc: "HINSTANCE".} = pointer
+  when defined(cpp):
+    type
+      THINSTANCE {.importc: "HINSTANCE".} = object
+        x: pointer
+    proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {.
+        importcpp: "(void*)GetProcAddress(@)", header: "<windows.h>", stdcall.}
+  else:
+    type
+      THINSTANCE {.importc: "HINSTANCE".} = pointer
+    proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {.
+        importc: "GetProcAddress", header: "<windows.h>", stdcall.}
 
   proc freeLibrary(lib: THINSTANCE) {.
       importc: "FreeLibrary", header: "<windows.h>", stdcall.}
   proc winLoadLibrary(path: cstring): THINSTANCE {.
       importc: "LoadLibraryA", header: "<windows.h>", stdcall.}
-  proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {.
-      importc: "GetProcAddress", header: "<windows.h>", stdcall.}
 
   proc nimUnloadLibrary(lib: TLibHandle) =
     freeLibrary(cast[THINSTANCE](lib))