-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunction.py
More file actions
21 lines (18 loc) · 527 Bytes
/
Copy pathfunction.py
File metadata and controls
21 lines (18 loc) · 527 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import ctypes
NUM = 16
# libfun loaded to the python file
# using fun.myFunction(),
# C function can be accessed
# but type of argument is the problem.
fun = ctypes.CDLL("libfun.so") # Or full path to file
# Now whenever argument
# will be passed to the function
# ctypes will check it.
fun.myFunction.argtypes = [ctypes.c_int]
# now we can call this
# function using instant (fun)
# returnValue is the value
# return by function written in C
# code
returnVale = fun.myFunction(NUM)
print(returnVale)