Although this is still a bit inconvenient, it is possible to keep DLL
loaded by incrementing reference count itself.

/* test.c */

#ifdef WIN32
# include <windows.h>
#else
# include <dlfcn.h>
#endif

#ifdef _MSC_VER
# define EXPORT __declspec(dllexport)
#else
# define EXPORT
#endif

EXPORT int load(char *path);
EXPORT int count();

int load(char *path) {
#ifdef WIN32
 return (LoadLibrary(path) != NULL);
#else
 return (dlopen(path, RTLD_LAZY) != NULL);
#endif
}

static int x = 0;

int count() {
 return ++x;
}



" test.vim

let dll = has("win32") ? "test.dll" : "test.so"
call libcallnr(dll, "load", dll)
for i in range(10)
 echo libcallnr(dll, "count", 0)
endfor


--
Yukihiro Nakadaira - [EMAIL PROTECTED]

Reply via email to