prefer consts to importing #defines from headers

to be completed - better would be to have a libc wrapper that deals with
all pesky C ABI details
This commit is contained in:
Jacek Sieka 2016-06-06 23:00:00 +08:00
commit 8d7a45f205
6 changed files with 65 additions and 39 deletions

View file

@ -52,11 +52,14 @@ when defined(posix):
#
# c stuff:
var
RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
when defined(linux) or defined(macosx):
const RTLD_NOW = cint(2)
else:
var
RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: cint
proc dlclose(lib: LibHandle) {.importc, header: "<dlfcn.h>".}
proc dlopen(path: cstring, mode: int): LibHandle {.
proc dlopen(path: cstring, mode: cint): LibHandle {.
importc, header: "<dlfcn.h>".}
proc dlsym(lib: LibHandle, name: cstring): ProcAddr {.
importc, header: "<dlfcn.h>".}