Skip to content

Instantly share code, notes, and snippets.

@framsc
Forked from nicolamontecchio/ctypes_stuff.py
Created January 5, 2019 15:28
Show Gist options
  • Save framsc/d78be68a14f84150fa2b7a1ff256c6b4 to your computer and use it in GitHub Desktop.
Save framsc/d78be68a14f84150fa2b7a1ff256c6b4 to your computer and use it in GitHub Desktop.
python ctypes - array conversion
#let's say f_TI is something like
#void blabla(int *data, int data_length);
#then
f_TI.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.c_int]
lll = [4,7,2,8]
lll_c = (ctypes.c_int * len(lll))(*lll)
f_TI(lll_c, len(lll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment