Reputation: 1562
I know that python int can be converted into an c int type using ctypes.
But how do I convert a python int into an int16_t type?
I have tried:
import ctypes as ct
my_c_number = ct.c_int16_t(1)
#Apparently ctypes library does not have c_int16_t attribute.
Upvotes: 3
Views: 10412
Reputation: 473
How about ctypes.c_int16
? Also supports ctypes.c_uint16
if you are looking for that.
Documentation:
https://docs.python.org/2/library/ctypes.html#ctypes.c_int16 and
https://docs.python.org/2/library/ctypes.html#ctypes.c_uint16
Upvotes: 1