Skip to content

Instantly share code, notes, and snippets.

@LAK132
Last active July 30, 2018 09:05
Show Gist options
  • Save LAK132/5c208dd769f8698ea78e3baecaf54cbc to your computer and use it in GitHub Desktop.
Save LAK132/5c208dd769f8698ea78e3baecaf54cbc to your computer and use it in GitHub Desktop.
PY_EXPORT
from sys import platform
from ctypes import cdll, CDLL
from ctypes import sizeof, c_void_p
def loadlibrary(name):
'''loads library "name[32/64/...][.dll/.so]" depending on platform'''
return CDLL((name+"{}{}").format(sizeof(c_void_p)*8, "" if platform=="win32" else ".so"))
#ifndef PY_EXPORT
# if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
# define PY_EXPORT extern "C" __declspec(dllexport)
# else
# define PY_EXPORT extern "C"
# endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment