'Convert python int into int16_t type
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.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | neerad29 |