Skip to content

Instantly share code, notes, and snippets.

@imgVOID
Forked from dpoulopoulos/padd.py
Last active October 3, 2021 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imgVOID/333c7a2bc4c4ff19edc8ac0e034343f3 to your computer and use it in GitHub Desktop.
Save imgVOID/333c7a2bc4c4ff19edc8ac0e034343f3 to your computer and use it in GitHub Desktop.
import ctypes
import pathlib
if __name__ == "__main__":
# загрузка библиотеки
libname = pathlib.Path().absolute() / "libcadd.so"
c_lib = ctypes.CDLL(libname)
x, y = 6, 2.3
# обозначение типа данных возвращаемого значения
c_lib.cadd.restype = ctypes.c_float
# вызов функции с корректными указанными типами данных
res = c_lib.cadd(x, ctypes.c_float(y))
print(f"В Python: int: {x} float {y:.1f} return val {res:.1f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment