mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 23:05:27 +00:00
BUGFIX: better error message when loading of dynamic lib proc fails
This commit is contained in:
@@ -60,6 +60,7 @@ when defined(posix):
|
||||
|
||||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
|
||||
result = dlsym(lib, name)
|
||||
if result == nil: nimLoadLibraryError($name)
|
||||
|
||||
elif defined(windows) or defined(dos):
|
||||
#
|
||||
@@ -84,6 +85,7 @@ elif defined(windows) or defined(dos):
|
||||
|
||||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
|
||||
result = GetProcAddress(cast[THINSTANCE](lib), name)
|
||||
if result == nil: nimLoadLibraryError($name)
|
||||
|
||||
elif defined(mac):
|
||||
#
|
||||
@@ -114,11 +116,12 @@ elif defined(mac):
|
||||
NSDestroyObjectFileImage(img)
|
||||
result = TLibHandle(modul)
|
||||
|
||||
proc nimGetProcAddr(lib: TLibHandle, cname: string): TProcAddr =
|
||||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
|
||||
var
|
||||
nss: NSSymbol
|
||||
nss = NSLookupSymbolInModule(NSModule(lib), name)
|
||||
result = TProcAddr(NSAddressOfSymbol(nss))
|
||||
if result == nil: nimLoadLibraryError($name)
|
||||
|
||||
else:
|
||||
{.error: "no implementation for dyncalls".}
|
||||
|
||||
Reference in New Issue
Block a user