-
-
Save imgVOID/333c7a2bc4c4ff19edc8ac0e034343f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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